Commands using sudo (474)

  • Back up /etc directory with a name based on the current date and the hostname of the machine, then chown the file for the current user for use.

    sudo tar -zcvf $(hostname)-etc-back-`date +%d`-`date +%m`-`date +%y`.tar.gz /etc && sudo chown $USER:$USER $(hostname)-etc-back*
    thanosme · 2013-08-18 12:49:11 0
  • bit of a contrived example and playing to my OCD but nice for quick scripted output of listening ports which is sorted by port, ip address and protocol. Show Sample Output

    sudo netstat -plntu --inet | sort -t: -k2,2n | sort --stable -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | sort -s -t" " -k1,1
    thechile · 2013-08-13 09:21:26 0
  • ..not guaranteed to always be accurate but fun to see how old you Linux installation is based on the root partitions file system creation date. Show Sample Output

    sudo tune2fs -l $(df -h / |(read; awk '{print $1; exit}')) | grep -i created
    thechile · 2013-08-08 15:18:09 5

  • -1
    sudo netstat -tulpn | grep :8080
    BU5T4 · 2013-07-30 13:10:50 0
  • Assumes XP/2000/2003. For Server 2008+ try offset=105,906,176 You can find this number in the System Information utility under Partition Starting Offset. UEFI based boxes you want partition 2 since the first is just the boot files (and FAT). This works with (storage side) snapshots which is handy for single file restores on NFS mounted VMware systems Show Sample Output

    sudo mount vmware-server-flat.vmdk /tmp/test/ -o ro,loop=/dev/loop1,offset=32768 -t ntfs
    JeremyinNC · 2013-07-29 14:45:29 0
  • If you are an unlucky soul behind a corporate firewall you will likely find that downloading gpg keys is blocked. This is because the hkp protocol uses port 11371 by default to transfer the key. By adding "hkp://" to the beginning of the hostname and ":80" to the end you are asking gpg to try using port 80 to connect (less likely to be blocked by a firewall). This relies on the remote server answering to requests over port 80. Show Sample Output

    sudo apt-key adv --keyserver hkp:// --recv-keys [key to get here]
    phattmatt · 2013-07-23 08:29:40 0

  • 0
    sudo port selfupdate && sudo port upgrade outdated && sudo port clean --all installed && sudo port -f uninstall inactive
    noah · 2013-06-26 01:12:33 0

  • 0
    sudo dumpe2fs /dev/sda1 | grep superblock
    rugina · 2013-06-25 08:48:49 0
  • Counts of messages by recipient, with frozen messages excluded. Show Sample Output

    sudo /usr/sbin/exim -bp | sed -n '/\*\*\* frozen \*\*\*/,+1!p' | awk '{print $1}' | tr -d [:blank:] | grep @ | sort | uniq -c | sort -n
    blueskin · 2013-06-04 10:49:14 0
  • Inner "ps...grep..." command searches for a process matching the specified . "lsof -p lists all file descriptors owned by . Includes open files, sockets, devices, etc... Show Sample Output

    sudo lsof -p `sudo ps aux | grep -i neo4j | grep -v grep | awk '{ print $2 }'`
    andycunn · 2013-06-02 10:15:30 1

  • 1
    sudo apt-cache dumpavail | grep Package | cut -d ' ' -f 2 > available.packages
    mered · 2013-05-18 20:42:22 1

  • -1
    sudo systemctl enable lxdm
    unixmonkey57489 · 2013-05-16 14:44:55 0

  • -1
    sudo reboot
    unixmonkey57489 · 2013-05-16 14:43:41 0
  • To do this, we?ll use nano to create a new configuration file called ?virtualbox.conf?. This file will go in the ?/etc/modules-load.d? directory, which contains files that need to be loaded when Arch boots up. Since adding a file to this directory requires administrative permissions, we?ll need to precede our command with ?sudo? once again. When nano brings up the blank file, add these three lines to it: vboxguest vboxsf vboxvideo As usual, when you?re finished entering text in nano, type Control-X to exit to the command line, and answer ?y? for yes when you?re asked whether you want to save your work, and then hit ?Return? to accept the filename. At this point, reboot your machine for the Guest Additions to take effect.

    sudo nano /etc/modules-load.d/virtualbox.conf
    unixmonkey57489 · 2013-05-16 14:41:51 0
  • Here you have to choose the correct kernel number, for example linux38.

    sudo pacman -S virtualbox-guest-utils
    unixmonkey57489 · 2013-05-16 14:39:38 0
  • If not success clean cache and try again Code: [Select] Show Sample Output

    sudo pacman -Scc
    unixmonkey57489 · 2013-05-16 14:19:14 0
  • 00 is the number of the linux kernel e.g. linux39

    sudo mhwd-kernel linux00
    unixmonkey57489 · 2013-05-16 14:02:46 0

  • 0
    sudo pacman-mirrors -g
    unixmonkey57489 · 2013-05-16 13:55:39 0
  • Warning: Instead of immediately updating as soon as updates are available, users must recognize that due to the nature of Arch's rolling release approach, an update may have unforeseen consequences. This means that it is not wise to update if, for example, one is about to deliver an important presentation. Rather, update during free time and be prepared to deal with any problems that may arise. Pacman is a powerful package management tool, but it does not attempt to handle all corner cases. Read The Arch Way if this causes confusion. Users must be vigilant and take responsibility for maintaining their own system. When performing a system update, it is essential that users read all information output by pacman and use common sense. If a user-modified configuration file needs to be upgraded for a new version of a package, a .pacnew file will be created to avoid overwriting settings modified by the user. Pacman will prompt the user to merge them. These files require manual intervention from the user and it is good practice to handle them right after every package upgrade or removal. See Pacnew and Pacsave Files for more info. Tip: Remember that pacman's output is logged in /var/log/pacman.log. Show Sample Output

    sudo pacman -Syu
    unixmonkey57489 · 2013-05-16 13:49:14 0

  • 0
    sudo useradd -U -m -s /bin/bash new_user
    monmo · 2013-04-29 06:32:49 0

  • 0
    sudo su; sync; echo 3 > /proc/sys/vm/drop_caches
    ab_simas · 2013-04-23 14:07:15 0

  • 0
    sudo shutdown -h now
    permanaj · 2013-04-23 02:34:48 0
  • this command also can run the last command as root what's more, sudo !-2 can run the second last command as root , and so on

    sudo !-1
    datamining · 2013-04-22 03:45:14 0
  • wait a hour and 10 seconds to shutdown Show Sample Output

    sudo shutdown -h <hour:minute>
    devlucas · 2013-04-19 18:54:38 0
  • Advanced information about RAM.

    sudo dmidecode --type 17
    FadeMind · 2013-04-18 20:13:07 0
  • ‹ First  < 3 4 5 6 7 >  Last ›

What's this? 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.


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: