[clug] .bash_aliases and .bashrc

George at Clug Clug at goproject.info
Sat Oct 18 14:41:01 MDT 2014


    Scott, 

To answer your question "I'd also be interested in what other people
find useful", so far I do not often use scripts, when I do they are
run as root, so I use su and then run in the terminal as root until I
use 'exit' to exit from su. I find sudo a pain to use, so when forced
to do so, I like 'sudo su'.  I guess this is not the "recommended"
way to work, but I am used to being the "Administrator" in Windows
environments. (any comments ?)

At times I use gksu;

gksu [-u ] [options] 
gksu nautilus

The gksu command also has a few other tricks up its sleeve – it
preserves your current desktop settings, so graphical programs won’t
look out of place when you launch them as a different user. Programs
such as gksu are the preferred way of launching graphical applications
with root privileges.

Gksu uses either a su or sudo-based backend, depending on the Linux
distribution you’re using.
http://www.howtogeek.com/111479/htg-explains-whats-the-difference-between-sudo-su/

Below information provides basic explanation about these commands;

The difference between sudo and su is how they perform authentication:

    su prompts for the target user's password.
    sudo checks whether the source user is authorized to run the
command (the authorization is specified in /etc/sudoers). Depending on
the configuration, it might prompt for the source user's password,
both to mitigate the risk of an unattended console and to alert the
user that privilege escalation is going on.

Once authorized, the effect is the same: run a command as root (or, if
specified on the command line, as some other user).

http://www.cyberciti.biz/open-source/command-line-hacks/linux-run-command-as-different-user/

---------------------------------------------
1) Required Password:
    ‘sudo’ requires current user password.
    Whereas, ‘su -c’ requires root user password. (This is no
coincidence. Infact, this was the very reason for introduction of sudo
command).

3) It’s working:
    On issuing the ‘sudo’ command, os checks the sudoers file
in /etc directory for a flag which tells is whether or not root like
permission should be given to current user.
    On the other hand, when ‘su -c’ means, switch to super
user(root) and -c switch says, only for this command.

4) Time Duration:
    Since, ‘su -c’ command elevates permission for only
specified command, you need to enter root password, each time it is
used.
    Whereas, on entering password for sudo command, it gives root
like permissions for about 5 minutes. i.e. you don’t need to enter
password again if you issue sudo command again.
http://blog.idifysolutions.com/2011/09/difference-between-sudo-su-c-commands/

George.

At Saturday, 18-10-2014 on 21:22 Scott Ferguson wrote:


People have posted their favourites before...
Here's a couple I use that I haven't seen elsewhere. Peer review
wouldn't hurt me.

I'd also be interested in what other people find useful.

Replace "su -c" with "sudo" if you use it.

~/.bash_aliases

alias Check="su -c 'apt-get update;apt-get -s upgrade | more'"
alias Dmsg="dmesg | grep -i 'warn\|fail\|error\|alert'"
alias Vms="ssh scott at vbserver 'vboxmanage list runningvms'"
alias halt="su -c halt" # for systems without a windowmanager
alias whois="whois -H"
alias wgets='H="--header"; wget $H="Accept-Language: en-us,en;q=0.5"
$H="Accept: text/html,application/xh
tml+xml,application/xml;q=0.9,*/*;q=0.8" $H="Connection: keep-alive"
-U
"Mozilla/5.0 (Windows NT 5.1; rv:
10.0.2) Gecko/20100101 Firefox/10.0.2" --referer=http://google.com/ '
alias upgradeflash="su -c 'update-flashplugin-nonfree --install'"
alias upgradecalibre="su -c newcalibre"
alias dmsg='su -c "cat /var/log/messages | grep -v PROT | tail -n 32"'
alias Temp='hddtemp /dev/sda'
alias resolv='su -c "cp /home/scott/Scripts/resolv.conf /etc"'


~/.bashrc

function pause(){
echo "Press the Any key to continue..."
   read -p "$*"
}

# uses ~/.ssh/config
function sscreen(){
ssh -t "$1" screen -dR
}

function Size(){
echo -n "$1 = "
du -ch "$1" | tail -n1 | cut -f1
}



Kind regards
-- 
linux mailing list
linux at lists.samba.org
https://lists.samba.org/mailman/listinfo/linux




More information about the linux mailing list