How do I find the largest top 10 files and directories

du -a /var | sort -n -r | head -n 10

Show raw control characters

less -RXs

How to tar and gzip a folder in one line

tar cvf - /home/ebs | gzip - > ebs.tar.gz

Find the five biggest files on your system

find / -type f -printf '%s %p\n' |sort -nr| head -5

or in more human readable form:

find ~ -type f -print0| xargs -0 ls -s | sort -rn | awk '{size=$1/1024; printf("%dMb %s\n", size,$2);}' | head -5

List the top five largest directories or files in the named directory

du -a ~ | sort -nr | head -n 5

What files were changed on this day, in the current directory?

ls -lrt | awk '{print $6" "$7" "$9 }' | grep 'May 22'

How much space is left on my hard drive or drives?

df -hT | egrep -i "file|^/"

N.B. Miss out the -T for Macosx

Command to identify distribution

lsb_release -a

or (Red Hat only)

cat /etc/redhat-release

Could also try:

  1. dmesg | head -1
  2. cat /proc/version
  3. egrep '^title' /boot/grub/menu.lst

Command to see ubuntu version

lsb_release -a


<Ctrl><Alt>F2. To get back to your X, <Ctrl><Alt>F7.

Uze zip but exclude a directory

zip -r ./  -x "wordpress/*"

Force $SHELL to be /bin/bash

chsh -s /bin/bash ccaaabi

Biggest file/directories

  1. du -a /var | sort -n -r | head -n 10

Show timestamp

To display the current UNIX Timestamp:

date +%s


See Ubuntu page

Red Hat

See Red Hat page

Serve the current directory at http://localhost:8000/

python -m SimpleHTTPServer

To get wikipeida entry on say Java:

 dig +short txt

To find a file:

find . -name *pcp*

To find a file containing 'string':

find $start_dir -type f -exec grep -li '$string' {} \;

Find inode of a file

Find out file inode

First find out file inode number with any one of the following command:

stat {file-name}


ls -il {file-name}

Delete or remove files with inode number

$ find . -inum 782263 -exec rm -i {} \;

To find file with in x days old

find $start_dir -type f -mtime -$within_days  -print

To unzip a .zip file:

unzip <file> ! if .zip
bunzip2 <file> ! if .bz2

To convert Dos file to Unix:

tr '\015' '\012' < ChangeStyle.js >

To find out what kind of RAM:

sudo dmidecode

Whoami, and what groups am I in
$ id

The directory /home/cormany/scripts is not in your path.

# export PATH=${PATH}:/home/cormany/scripts
# echo $PATH

The parameter list is too long

$ getconf ARG_MAX

To colour your grep output (in .profile) :

export GREP_COLOR='1;30;43'; alias grep="grep --color=auto"

Alias history command

alias hh='history'

Exclude certain files/directories from tar:

$ tar cvf    UCL_OLM_AUDIO.tar --exclude "/Users/admin/UCL_OLM_AUDIO.pwf/Contents/Resources/Movies"  --exclude "*.svn*" ./*

N.B. ‘—exclude-vcs’

Exclude files and directories used by following version control systems: ‘CVS’, ‘RCS’, ‘SCCS’, ‘SVN’, ‘Arch’, ‘Bazaar’, ‘Mercurial’, and ‘Darcs’. Also: —exclude-from=file

The tree command:

alias tree='find . -print | sed -e '\''s;[^/]*/;|____;g;s;____|; |;g'\'' '

Open nautilus in current dir

nautilus ./

Open nautilus in a given directory

nautilus ./

How big is my home directory?

du -hs ~

Ctrl-x Ctrl-e

Takes what you currently have on the commandline and dumps it into your default editor. To set your default editor, type export EDITOR=vim or add that line to your ~/.bashrc to set it permanently. This is useful for editing long and complex commands or if your terminal is behaving strangely, which I sometimes find happens at the bottom of the screen. When you save and exit the editor, the command will run.i

mount | column -t

Shows your current mountpoints in a nice table. column is a very handy little utility that I hadn't encountered before. It takes input and turns it into, yep, columns. -t formats them as a table. It will try to guess the number of columns, or you can set them with the -c option. This is potentially useful for quick-and-dirty eyeballing of all sorts of data.

Editing a block of commands

You can also edit a block of commands. Let's say you executed a series of commands, between numbers 1478 and 1482, with a particular value, and want to edit them all. (Maybe you did a series of things to a file or a directory, and now want to repeat the sequence with another file.) Use this command:

fc 1478 1482

untar zip file

$ tar xfvz GoogleMapAPI-2.5.tar.gz
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License