Short alias for sudo

alias s='sudo'
This is way faster than typing 'sudo'. And AFAIK - there is no decent command for letter 's'.

-12
By: eimantas
2010-04-17 11:30:55

These Might Interest You

  • I didn't come up with this myself, but I always add this to my .bash_aliases file. It's essentially the same idea as running "sudo !!" except it's much easier to type. (You can't just alias "sudo !!", it doesn't really work for reasons I don't understand.) "fc" is a shell built-in for editing and re-running previous commands. The -l flag tells it to display the line rather than edit it, and the -n command tells it to omit the line number. -1 tells it to print the previous line. For more detail: help fc


    1
    alias please='sudo $(fc -ln -1)'
    suspenderguy · 2018-06-13 20:20:19 1
  • By default sudo 'remembers' password for a few minutes, so that you do not need to re-enter password for a series of sudo commands that might follow within a short time duration. However, sometime you might want sudo to instantly 'forget' the password. (Next sudo command will need you to reenter the password) Credit: I first learned this while listening to one of the 'tuxradar' podcast. Show Sample Output


    17
    sudo -K
    b_t · 2010-10-05 12:44:26 0
  • This alias is quicker to type than 'sudo apt-get install', and it automatically says yes to the prompt that shows up sometimes.


    0
    alias sagi="yes | sudo apt-get install"
    theepicsnail · 2011-03-06 03:45:47 1
  • Run program as root by SSH key forwarding instead of sudoers. Put this alias line in .bashrc or wherever you like. Alias arguments might need extra escaping. You might wonder about security. But you'd block out root login as much as possible of course. In sshd_config you put this: PermitRootLogin no Match Address 127.0.0.1   PermitRootLogin without-password


    -2
    alias sshdo='ssh -q -t root@localhost -- cd $PWD \&\& sudo'
    darkfader · 2010-10-20 22:33:22 5

What Others Think

What I do is add the command I want to sudo more then once to sodoers. Then add the whole command into my alias file. e.g. alias tail='sudo tail' with the following in sudoers: user ALL=NOPASSWD: /usr/bin/tail That way I can use the standard command with the sudo rights. As I have edited sudoers, I do not need to enter the password.
houghi · 427 weeks and 1 day ago
Why? I mean, it's only four letters...
kaedenn · 427 weeks ago
I think there is a natural alias for 's' - it's one of the most common typos for ls namely the "hit enter just too early"-typo
funky · 426 weeks and 6 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: