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

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"

Rename files in batch

Download an Entire website with wget

Run a program transparently, but print a stack trace if it fails
For automated unit tests I wanted my program to run normally, but if it crashed, to add a stack trace to the output log. I came up with this command so I wouldn't have to mess around with core files. The one downside is that it does smoosh your program's stderr and stdout together.

Get AWS temporary credentials ready to export based on a MFA virtual appliance
You might want to secure your AWS operations requiring to use a MFA token. But then to use API or tools, you need to pass credentials generated with a MFA token. This commands asks you for the MFA code and retrieves these credentials using AWS Cli. To print the exports, you can use: `awk '{ print "export AWS_ACCESS_KEY_ID=\"" $1 "\"\n" "export AWS_SECRET_ACCESS_KEY=\"" $2 "\"\n" "export AWS_SESSION_TOKEN=\"" $3 "\"" }'` You must adapt the command line to include: * $MFA_IDis ARN of the virtual MFA or serial number of the physical one * TTL for the credentials

a short counter
Maybe you know shorter ?

Log colorizer for OSX (ccze alternative)
Download colorizer by @raszi @ http://github.com/raszi/colorize

Hold off any screensavers/timeouts
Moves the mouse 1 pixel down and to the right, then immediately back again, every 4 minutes. This keeps screensavers from turning on. I have used this extensively and I've never even noticed the mouse movement because it is so subtle.

back ssh from firewalled hosts
host B (you) redirects a modem port (62220) to his local ssh. host A is a remote machine (the ones that issues the ssh cmd). once connected port 5497 is in listening mode on host B. host B just do a ssh 127.0.0.1 -p 5497 -l user and reaches the remote host'ssh. This can be used also for vnc and so on.

Get your outgoing IP address


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: