Usefull Linux Shell Commands

Check all running services
ps xa

Find a particular process
ps xa | grep processName

Kill a process
kill -KILL processPID

Close the current process
ctrl + c

Sleep a process
ctrl + z

Put the process to the background (where n is job number)
bg %n

Bring the process to the foreground (where n is job number)
fg %n

Show the list of current jobs
jobs

Search command history
ctrl + r

View a file page by page
cat somefile | less

Search for a file containing some string
grep -lir "searchstring" ~/somedir/*

Display the current path
pwd

Show kernel modules currently loaded
lsmod

Find a file
locate file

Create a gzip archive
tar -czf output.tar.gz input files

Secure copy from local to remote
scp localfile username@servername:/home/username/

Find all files that end in ‘.c’, contain the text “what i want” but not the text “what i dont”:
find . -name "*.c" -exec grep -lR 'what/ i/ want' {} \; | xargs grep -L 'what/ i/ dont'

Check all running services
ps xa

Find a particular process
ps xa | grep processName

Kill a process
kill -KILL processPID

Close the current process
ctrl + c

Sleep a process
ctrl + z

Put the process to the background (where n is job number)
bg %n

Bring the process to the foreground (where n is job number)
fg %n

Show the list of current jobs
jobs

Search command history
ctrl + r

View a file page by page
cat somefile | less

Search for a file containing some string
grep -lir "searchstring" ~/somedir/*

Display the current path
pwd

Show kernel modules currently loaded
lsmod

Find a file
locate file

Remount the filesystem in read/write
mount -o remount,rw /

Determine file type, architecture, etc:
file somefile

Search for sometext in a number of PDF files:
ls *.pdf | xargs -I{} pdftotext {} - | grep "sometext"

Read a binary file in hex:
od -c filename | less

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s