Commands using echo (1,545)

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

Monitor TCP opened connections

Empty a file

Unaccent an entire directory tree with files.
This command changes all filename and directories within a directory tree to unaccented ones. I had to do this to 'sanitize' some samba-exported trees. The reason it works might seem a little difficult to see at first - it first reverses-sort by pathname length, then it renames only the basename of the path. This way it'll always go in the right order to rename everything. Some notes: 1. You'll have to have the 'unaccent' command. On Ubuntu, just aptitude install unaccent. 2. In this case, the encoding of the tree was UTF-8 - but you might be using another one, just adjust the command to your encoding. 3. The program might spit a few harmless errors saying the files are the same - not to fear.

Compute the average number of KB per file for each dir
Use this to find identify if dirs mostly contain large or small files.

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

Prevent non-root users from logging in
Also with optional message: $ echo "no login for you" > /etc/nologin (This doesn't affect your current X session - you're already logged in!)

xargs for builtin bash commands
Similar to xargs -i, but works with builtin bash commands (rather than running "bash -c ..." through xargs)

Extract ip addresses with sed
Extracts ip addressess from file using sed. Uses a tag(ip) to grep the IP lines after extracting. Must be a way to just output regex matched on sed.

Exclude inserting a table from a sql import
Starting with a large MySQL dump file (*.sql) remove any lines that have inserts for the specified table. Sometimes one or two tables are very large and uneeded, eg. log tables. To exclude multiple tables you can get fancy with sed, or just run the command again on subsequently generated files.

ps a process keeping the header info so you know what the columns of numbers mean!
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1828 0.0 0.0 5396 476 ? Ss 2008 0:00 /usr/sbin/sshd


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: