Commands using sudo (537)


  • 0
    sudo apt-get install lamp-server^ phpmyadmin
    imericurnot · 2012-11-15 01:08:00 10

  • 0
    sudo ettercap -T -Q -M arp -i wlan0 // //
    jorgemendoza · 2012-11-20 23:42:53 14
  • Magic line will extract almost all possible archives from current folder in its own folders. Don't forget to change USER name in sudo command. sed is used to create names for folders from archive names w/o extension. You can test sed expression, used in this command: arg='war.lan.net' ; x=$(echo $arg|sed 's/\(.*\)\..*/\1/') ; echo $x If some archives can't be extracted, install packages: apt-get install p7zip-full p7zip-rar Hope this will save a lot of your time. Enjoy.


    0
    for ARG in * ; do sudo -u USER 7z x -o"$(echo $ARG|sed 's/\(.*\)\..*/\1/')" "$ARG" ; done
    n158 · 2012-12-31 19:47:24 7
  • MAC OSX doesn't come with a locate command, This will do the same thing as the locate command on a typical Linux OS. Simply add it to your ~/.bash_profile


    0
    alias locate='if [ $((`date +%s`-`eval $(stat -s /var/db/locate.database); echo $st_mtime`)) -gt 3600 ]; then echo "locate: db is too old!">/dev/stderr; sudo /usr/libexec/locate.updatedb; fi; locate -i'
    jhyland87 · 2013-01-21 17:45:50 4

  • 0
    sudo apt-get <apt-get command and options> --print-uris -qq | sed -n "s/'\([^ ]\+\)' \([^ ]\+\) \([^ ]\+\) MD5Sum:\([^ ]\+\)/wget -c \1/p" > dowload_deb_list.txt
    totti · 2013-02-09 09:36:53 4

  • 0
    sudo port selfupdate ; echo '---------' ; sudo port upgrade outdated
    roozbeh · 2013-03-21 04:07:54 4
  • Your computer's name is raspberrypi and you want to rename it to pita1. This command will change both the hostname and the name used for netwrk communications.


    0
    sudo sed -i 's/raspberrypi/pita1/' /etc/hosts /etc/hostname; sudo reboot
    egeoffray · 2013-04-16 07:27:41 6
  • Install Ksuperkey one command in Kubuntu. You must manually add ksuperkey to autostart in System Settings KDE.


    0
    sudo apt-get install git gcc make libx11-dev libxtst-dev pkg-config -y && git clone https://github.com/hanschen/ksuperkey.git && cd ksuperkey && make && sudo mv ksuperkey /usr/bin/ksuperkey && cd ~ && rm -rf ksuperkey
    FadeMind · 2013-04-17 07:12:46 6
  • Replace default command in skype.desktop file.


    0
    sudo sed -i 's/Exec=skype %U/Exec=skype --disable-cleanlooks -style GTK %U/' /usr/share/applications/skype.desktop
    FadeMind · 2013-04-17 08:43:00 6
  • Advanced information about RAM.


    0
    sudo dmidecode --type 17
    FadeMind · 2013-04-18 20:13:07 4
  • wait a hour and 10 seconds to shutdown Show Sample Output


    0
    sudo shutdown -h <hour:minute>
    devlucas · 2013-04-19 18:54:38 26

  • 0
    sudo shutdown -h now
    permanaj · 2013-04-23 02:34:48 5

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

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

  • 0
    sudo pacman-mirrors -g
    unixmonkey57489 · 2013-05-16 13:55:39 7
  • Here you have to choose the correct kernel number, for example linux38.


    0
    sudo pacman -S virtualbox-guest-utils
    unixmonkey57489 · 2013-05-16 14:39:38 14
  • 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


    0
    sudo lsof -p `sudo ps aux | grep -i neo4j | grep -v grep | awk '{ print $2 }'`
    andycunn · 2013-06-02 10:15:30 7
  • Counts of messages by recipient, with frozen messages excluded. Show Sample Output


    0
    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 8

  • 0
    sudo dumpe2fs /dev/sda1 | grep superblock
    rugina · 2013-06-25 08:48:49 182

  • 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 10
  • 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


    0
    sudo apt-key adv --keyserver hkp://keys.gnupg.net:80 --recv-keys [key to get here]
    phattmatt · 2013-07-23 08:29:40 7
  • 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


    0
    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 8
  • 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.


    0
    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 19

  • 0
    sudo adduser [username] lp && sudo adduser [username] lpadmin && sudo hp-setup -i
    Romero · 2013-08-25 14:21:25 10
  • Install all build dependencies for a given package Show Sample Output


    0
    sudo apt-get build-dep rhythmbox
    darlanalves · 2013-10-07 23:13:19 6
  • ‹ First  < 12 13 14 15 16 >  Last ›

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


Check These Out

Extract audio from a video

PRINT LINE the width of screen or specified using any char including Colors, Escapes and metachars
One of the first functions programmers learn is how to print a line. This is my 100% bash builtin function to do it, which makes it as optimal as a function can be. The COLUMNS environment variable is also set by bash (including bash resetting its value when you resize your term) so its very efficient. I like pretty-output in my shells and have experimented with several ways to output a line the width of the screen using a minimal amount of code. This is like version 9,000 lol. This function is what I use, though when using colors or other terminal features I create separate functions that call this one, since this is the lowest level type of function. It might be better named printl(), but since I use it so much it's more optimal to have the name contain less chars (both for my programming and for the internal workings). If you do use terminal escapes this will reset to default. $ tput sgr0 For implementation ideas, check my http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html

list block devices
Shows all block devices in a tree with descruptions of what they are.

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Figure out what shell you're running
short, sweet, and works after sudoing a new shell.

total percentage of memory use for all processes with a given name
This command will add up RAM usage of all processes whose name contains "java" and output the sum of percentages in HRF. Also, unlike the original #15430, it wont fail on processes with a usage of >9.9%. Pleases note that this command wont work reliably in use cases where a significant portion of processes involved are using less than 0.1% of RAM, because they will be counted as "0", even though a great number of them could add up to significant amounts.

watch iptables counters
This will allow you to watch as matches occur in real-time. To filter out only ACCEPT, DROP, LOG..etc, then run the following command: watch 'iptables -nvL | grep -v "0 0" && grep "ACCEPT"' The -v is used to do an inverted filter. ie. NOT "0 0"

How to copy CD/DVD into hard disk (.iso)
A dear friend of mine asked me how do I copy a DVD to your hard drive? If you want to make a copy of the ISO image that was burned to a CD or DVD, insert that medium into your CD/DVD drive and (assuming /dev/cdrom is associated with your computer?s CD drive) type the following command

Detect illegal access to kernel space, potentially useful for Meltdown detection
Based on capsule8 agent examples, not rigorously tested

Create a mirror of a local folder, on a remote server
Create a exact mirror of the local folder "/root/files", on remote server 'remote_server' using SSH command (listening on port 22) (all files & folders on destination server/folder will be deleted)


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: