commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. 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.
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
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.
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:
Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:
Create a persistent SSH connection to the host in the background. Combine this with settings in your ~/.ssh/config:
All the SSH connections to the machine will then go through the persisten SSH socket. This is very useful if you are using SSH to synchronize files (using rsync/sftp/cvs/svn) on a regular basis because it won't create a new socket each time to open an ssh connection.
"-o loop" lets you use a file as a block device
In this case it's better do to use the dedicated tool
Also works with:
chgrp --reference file1 file2
chown --reference file1 file2
Directly attach a remote screen session (saves a useless parent bash process)
If you want a visual representation of the parent/child relationships between processes, this is one easy way to do it. It's useful in debugging collections of shell scripts, because it provides something like a call traceback.
When a shell script breaks, just remember "awwfux".
This command shows the various shortcuts that can be use in bash, including Ctrl+L, Ctrl+R, etc...
You can translate "\C-y" to Ctrl+y, for example.
You can get one specific line during any procedure. Very interesting to be used when you know what line you want.
Of course you need to be able to access host A for this ;-)
If you enable multiuser, then you can permit others to share your screen session. The following conditions apply:
1. screen must be suid root;
2. "multiuser on" must be configured in ~/.screenrc;
3. control the others user(s) access with "aclchg":
# ----- from ~/.screenrc-users -----
aclchg someuser +rx "#?" #enable r/o access to "someuser"
aclchg someuser -x "#,at,aclchg,acladd,acldel,quit" # don't allow these
aclchg otheruser +rwx "#?" # enable r/w access to "otheruser"
aclchg otheruser -x "#,at,aclchg,acladd,acldel,quit" # don't allow them to use these commands
After doing this (once), you start your session with:
Then, the other user can join your terminal session(s) with youruserid:
$ screen -r youruserid/
Note: the trailing "/" is required.
Multiple users can share the same screen simultaneously, each with independent access controlled precisely with "aclchg" in the ~/.screenrc file.
I use the following setup:
# default screenrc on any host
Then, the base configurations are in ~/.screenrc-base; the host-specific configurations are in ~/.screenrc-$HOST, and the user configurations are in ~/.screenrc-users.
The host-specific .screenrc file might contain some host-specific screen commands; e.g.:
screen -t 'anywhere' /bin/tcsh
screen -t 'anywhere1' /bin/tcsh
The .screenrc-base contains:
## I find typing ^a (Control-a) awkward. So I set the escape key to CTRL-j instead of a.
termcapinfo xterm* ti@:te@:
Good for one off jobs that you want to run at a quiet time. The default threshold is a load average of 0.8 but this can be set using atrun.
just make some data scrolling off the terminal. wow.
This command takes a snapshot of the open files for a PID 1234 then waits 10 seconds and takes another snapshot of the same PID, it then displays the difference between each snapshot to give you an insight into what the application is doing.
Shorter, easier to remember version of cmd#7636
NTP is better, but there are situations where it can't be used. In those cases, you can do this to sync the local time to a server.
run 'nc yourip 5000', 'nc yourip 5001' or 'nc yourip 5002' elsewhere will produce an exact same mirror of your shell. This is handy when you want to show someone else some amazing stuff in your shell without giving them control over it.
Google just released a new commend line tool offering all sorts of new services from the commend line. One of them is uploading a youtube video but there are plenty more google services to interact with.
Download it here: http://code.google.com/p/googlecl/
This specific command courtesy of lifehacker:http://lifehacker.com/5568817/
Though all can be found in manual page linked above.
The empty file /forcefsck causes the file system check fsck to be run next time you boot up, after which it will be removed.
This works too:
-d: list directory entries instead of contents, and do not dereference symbolic links
Uses shell expansion to create a back-up called file.txt.bak
EDIT: command updated to support accented characters!
Works in any of 58 google supported languages (some sound like crap, english is the best IMO).
You get a mp3 file containing your query in spoken language. There is a limit of 100 characters for the "q" parameter, so be careful. The "tl" parameter contains target language.