# AllInOne: Update what packages are available, upgrade to new versions, remove unneeded packages # (some are no longer needed, replaced by the ones from ap upgrade), check for dependencies # and clean local cached packages (saved on disk but not installed?,some are needed? [this only cleans unneeded unlike ap clean]). # aliases (copy into ~/.bashrc file): alias a='alias' a ap='apt-get' a r='ap autoremove -y' a up='ap update' a u='up && ap upgrade -y --show-progress && r && ap check && ap autoclean' # && means "and run if the previous succeeded", you can change it to ; to "run even if previous failed". I'm not sure if ap check should be before or after ap upgrade -y, you can also change the alias names. # To expand aliases in bash use ctrl alt e or see this ow.ly/zBKHs # For more useful aliases go to ow.ly/zBMOx
Send a text message to an Kodi (XBMC) device. Uses curl to post a JSON request to the Kodi JSON-RPC API.
this command can be added to crontab so as to execute a nightly backup of directories and store only the 10 last backup files.
this command extracts an initrd files into the "tmp" directory
Also resolves hostname
To be OS independent you should try df -Pk first (Linux) and if it does not work (that's the ||) then use df -k (e.g. for Solaris, HP UX, AIX). To get the output in a single line, use the additional cat.
If you are on machine 1 and want to ssh into machine 3, but you can only do so from machine 2, this will do it all in one go. Note that once you are on machine 3 and exit () it will take you directly back to machine 1
Use this command to execute the contents of http://www.example.com/automation/remotescript.sh in the local environment. The parameters are optional.
Alterrnatives to wget:
CURL:
curl -s http://www.example.com/automation/remotescript.sh | bash /dev/stdin param1 param2
W3M:
w3m -dump http://www.example.com/automation/remotescript.sh | bash /dev/stdin [param1] [param2]
LYNX:
lynx -source http://www.example.com/automation/remotescript.sh | bash /dev/stdin [param1] [param2]
Copy the partition table from /dev/sda to /dev/sdb. Be careful to get your drive names right.
I had to reconfigure all of my 150 domains to use "localhost" as IMAP/SMTP server instead of mail.[domain]. This little thing did the job in a fraction of a second!
This command telnet and and looks for a line starting with "SSH" - works for OpenSSH since the SSH banner is something like "SSH-2.0-OpenSSH_6.0p1 Debian-4+deb7u3". Then it triggers an action accordingly.
It can be packed as a script file to echo 0/1 indicating the SSH service availability:
if [[ "$(sleep 1 | telnet -c <host> <port> 2>&1 | grep '^SSH')" == SSH* ]]; then echo 1; else echo 0; fi;
Alternative uses:
Trigger an action when server is UP (using &&):
[[ "$(sleep 1 | telnet -c <host> <port> 2>&1 | grep '^SSH')" == SSH* ]] && <command when up>
Trigger an action when server is DOWN (using ||):
[[ "$(sleep 1 | telnet -c <host> <port> 2>&1 | grep '^SSH')" == SSH* ]] || <command when down>
This command will find any named file types in / between two dates then will list all the metadata of those files in long format and human readable form. Adding a 't' flag to the ls command sorts the files by modified time. After all that the head -5 lists the first 5 which can be changed.
As output, checksums and filenames will be printed.
Don't use. This defines a function `:` that will create two more of itself, infinitely in the background. While this function is itself defined in the background, it is run up in the front.
Results will be shown in columns. Only different files and files in one directory that is not in the other will be shown.
uses the wonderful 'pv' command to give a progress bar when copying one partition to another. Amazing for long running dd commands Show Sample Output
To allow recursivity :
find -type f -exec md5sum '{}' ';' | sort | uniq -c -w 33 | sort -gr | head -n 5 | cut -c1-7,41-
Display only filenames :
find -maxdepth 1 -type f -exec md5sum '{}' ';' | sort | uniq -c -w 33 | sort -gr | head -n 5 | cut -c43-
Show Sample Output
Command to raise the volume. From https://wiki.archlinux.org/index.php/PulseAudio#Keyboard_volume_control
Compare the content of the files in the current directory with files of the same name in the duplicate directory.
Pop Quiz: You have a duplicate of a directory with files of the same name that might differ. What do you do?
You could use diff to compare the directories, but that's boring and it isn't as clever as find -print0 with xargs.
Note: You must omit stderr redirect 2>/dev/null to see the list of missing files from DUPDIR, if any.
Hint: Redirect stderr to a new file to produce a more readable list of files that are missing from DUPDIR.
Warning: This doesn't tell you if DUPDIR contains files not found in the current directory so don't delete DUPDIR.
Show Sample Output
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.
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
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: