tail

Lists in real time with continuous update the last lines of file

tail -f file

Lists the last m lines from file

tail -n m file

Lists starting from the m-th line

tail -n +m file

Uncategorized

head

Lists the first m lines from file

head -n m file

Uncategorized

touch

Creates file if it doesn’t exist of if exists resets atime,ctime and mtime.

Uncategorized

rm

Force remove (no confirmation)

rm -f

Forced recursive deletion :: EXTRA CARE when using any kind of / in the path : a space after the first / would delete EVERYTHING of the HD

rm -rf path

Uncategorized

cp

Recursive copy

cp -r

Preserves the owner, group and perms

cp -p

Forced copy (does not prompt to overwrite)

cp -f

Uncategorized

mv

Force move

mv -f

Update (moves only if the source is newer than the destination)

mv -u

Uncategorized

mkdir

Created dir and subdirs if needed (without -p it returns an error if a sub-parent also needs to be created)

mkdir -p path

Uncategorized

ls

Adds a file type identifier:

ls -F

Identifier:

/ => folder
@ => symbolic link
= => socket
| => pipe
* => executable

Lists files long format, ordered by size, human readable sizes

ls -lSh

List long ordered by mtime, newest first / oldest first

ls -lt
ls -rlt

List long ordered by atime, newest first / oldest first

ls -ult
ls -rult

List long ordered by ctime, newest first / oldest first

ls -clt
ls -rclt

Sort by mtime/ctime/atime

ls -t
ls -c
ls -u

List ordered by name and display the atime,ctime,mtime

ls -ul

ls -cl

ls -l

List by size long (bigger first)

ls -Sl

Recursive list

ls -R

Displays security context

ls -Z

Lists hidden files

ls -a

Lists file’s inode

ls -i

Lists information about the directory itself and not about it’s contents:

ls -d

Uncategorized

less

enter lists the next line

space lists the next screen

d down half a screen

u up half a screen

/string search for string downwards

?string search for string upwards

n next occurance

N previous occurance

g or < jump to the beginning of the file

G or > jump to the end of the file

Ctrl-G displays file info

Uncategorized

grep

Echo n lines of trailing (after) context lines

grep -A n patern file

Echo n lines of leading (before) context lines

grep -B n patern file

Echo n lines of output context lines

grep -C n patern file

Colorize the patern match

grep –color=always

Invert (select non-matching lines)

grep -v pattern file

Count the lines matched

grep -c pattern file

Ignore casing

grep -i pattern path

To only display files with matches

grep -l pattern path

To only displays files without matches

grep -L pattern path

To stop after displaying n lines for each file

grep -m n pattern path

To print the line of the match inside the containing file

grep -n pattern path

Search recursively

grep -R pattern path

grep -r pattern path

Skip files matching pattern ???????:

grep -r –exclude=pattern

Matches only the entire word

grep -w word path

Lists the filename where the pattern was found – default

grep -H pattern path

Uncategorized