Commands using sleep (289)

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

Sort a one-per-line list of email address, weeding out duplicates

password recovery on debian
Appended to grub boot parameters ... gives shell ... password recovery

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"

Find all the files more than 10MB, sort in descending order of size and record the output of filenames and size in a text file.
This command specifies the size in Kilobytes using 'k' in the -size +(N)k option. The plus sign says greater than. -exec [cmd] {} \; invokes ls -l command on each file and awk strips off the values of the 5th (size) and the 9th (filename) column from the ls -l output to display. Sort is done in reversed order (descending) numerically using sort -rn options. A cron job could be run to execute a script like this and alert the users if a dir has files exceeding certain size, and provide file details as well.

sudo for entire line (including pipes and redirects)
USAGE: $ sudor your command This command uses a dirty hack with history, so be sure you not turned it off. WARNING! This command behavior differ from other commands. It more like text macro, so you shouldn't use it in subshells, non-interactive sessions, other functions/aliases and so on. You shouldn't pipe into sudor (any string that prefixes sudor will be removed), but if you really want, use this commands: $ proceed_sudo () { sudor_command="`HISTTIMEFORMAT=\"\" history 1 | sed -r -e 's/^.*?sudor//' -e 's/\"/\\\"/g'`" ; pre_sudor_command="`history 1 | cut -d ' ' -f 5- | sed -r -e 's/sudor.*$//' -e 's/\"/\\\"/g'`"; if [ -n "${pre_sudor_command/ */}" ] ; then eval "${pre_sudor_command%| *}" | sudo sh -c "$sudor_command"; else sudo sh -c "$sudor_command" ;fi ;}; alias sudor="proceed_sudo # "

Graphically show percent of mount space used
Automatically drops mount points that have non-numeric sizes (e.g. /proc). Tested in bash on Linux and AIX.

colorize comm output
It just colorizes the line based on if it has 0, 1 or 2 tabs at the beginning of the line. Won't work so well if lines already begin with tabs (too bad comm doesn't have an option to substitute \t for something else). Don't forget comm needs input files to be sorted. You can use a shortcut like this with bash: comm

Create a bunch of dummy text files
Using the 'time' command, running this with 'tr' took 28 seconds (and change) each time but using base64 only took 8 seconds (and change). If the file doesn't have to be viewable, pulling straight from urandom with head only took 6 seconds (and change)

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)

Multiple variable assignments from command output in BASH
It's quite easy to capture the output of a command and assign it in a shell's variable: $ day=$(date +%d) $ month=$(date +%m) But, what if we want to perform the same task with just one program invocation? Here comes the power of eval! date(1) outputs a string like "day=29; month=07; year=11" (notice the semicolons I added on purpose at date's custom output) which is a legal shell line. This like is then parsed and executed by the shell once again with the help of eval. Just setting 3 variables! Inspired by LinuxJournal's column "Dave Taylor's Work the Shell".


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: