flogiston

Blog

More useful Linux commands

· admin · Linux

How to get some hardware info about your machine?
Execute this one: sudo lshw -html > info.htm
Source: colleague MV

From my colleague BV I got the following interesting site:
http://www.commandlinefu.com/commands/browse/sort-by-votes

A few of them:

sudo !!

Run the last command as root (Useful when you forget to use sudo for a command. "!!" grabs the last run command.)

^foo^bar

Runs previous command but replacing
Really useful for when you have a typo in a previous command. Also, arguments default to empty so if you accidentally run:
echo "no typozs"
you can correct it with

^z 
:w !sudo tee %

Save a file you edited in vim without the needed permissions
I often forget to sudo before editing a file I don't have write permissions on. When you come to save that file and get the infamous "E212: Can't open file for writing", just issue that vim command in order to save the file without the need to save it to a temp file and then copy it back again.

du -h --max-depth=1

List the size (in human readable form) of all sub folders from the current location

du -s * | sort -n | tail

Get the 10 biggest files/folders for the current direcotry

mkdir -p a/long/directory/path

Make directory including intermediate directories
This will create the intermediate directories that do not exist.