### Commands by anishchib (1) the last day the last week the last month all time sorted by date votes

• small -g option add user to initial login group (primary group). The group name must exist. Show Sample Output

0
useradd -g linux anish && id
· 2012-05-24 17:38:46

### 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.

### Check These Out

list block devices
Shows all block devices in a tree with descruptions of what they are.

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"

Show all detected mountable Drives/Partitions/BlockDevices
Yields entries in the form of "/dev/hda1" etc. Use this if you are on a new system and don't know how the storage hardware (ide, sata, scsi, usb - with ever changing descriptors) is connected and which partitions are available. Far better than using "fdisk -l" on guessed device descriptors.

Check a server is up. If it isn't mail me.
This version uses netcat to check a particular service.

Watch command
Repeat command after every 2 secs

embed referred images in HTML files
in "a.html", find all images referred as relative URI in an HTML file by "src" attribute of "img" element, replace them with "data:" URI. This useful to create single HTML file holding all images in it, as a replacement of the IE-created .mht file format. The generated HTML works fine on every other browser except IE, as well as many HTML editors like kompozer, while the .mht format only works for IE, but not for every other browser. Compare to the KDE's own single-file-web-page format "war" format, which only opens correctly on KDE, the HTML file with "data:" URI is more universally supported. The above command have many bugs. My commandline-fu is too limited to fix them: 1. it assume all URLs are relative URIs, thus works in this case: $but does not work in this case:$ This may not be a bug, as full URIs perhaps should be ignored in many use cases. 2. it only work for images whoes file name suffix is one of .jpg, .gif, .png, albeit images with .jpeg suffix and those without extension names at all are legal to HTML. 3. image file name is not allowed to contain "(" even though frequently used, as in "(copy of) my car.jpg". Besides, neither single nor double quotes are allowed. 4. There is infact a big flaw in this, file names are actually used as regular expression to be replaced with base64 encoded content. This cause the script to fail in many other cases. Example: 'D:\images\logo.png', where backward slash have different meaning in regular expression. I don't know how to fix this. I don't know any command that can do full text (no regular expression) replacement the way basic editors like gedit does. 5. The original a.html are not preserved, so a user should make a copy first in case things go wrong.

escape any command aliases
e.g. if rm is aliased for 'rm -i', you can escape the alias by prepending a backslash: rm [file] # WILL prompt for confirmation per the alias \rm [file] # will NOT prompt for confirmation per the default behavior of the command

Listing today’s files only

Convert filenames from ISO-8859-1 to UTF-8
Nothing advanced, it just finds filenames that are stored with ISO-8859-1 characters and and converts those into UTF-8. Recommended to use without the --notest flag first so you can see what will be changed.