Wednesday, July 16, 2014

Road to RHCE - Day 7

Day 7



Backup and Compression


To check the directory size

du -sh /etc/


To create an archive

tar -cvf [archive_name] [list_of_files]


To know the type of a file

file [filename]


To extract the contents of a tar file to a different path

tar -xvf [archive_name] -C [destination_path]


To compress an archive (or file)

zip [zip_filename] [source_filename]


To decompress a compressed file

unzip [zip_filename]


Using gzip (only for archives)

gzip [archive_filename]

[! gunzip [filename] to decompress]


Using bzip2 (more compression than gzip)

bzip2 [archive_filename]

[! bunzip2 [filename] to decompress]


To compress while archiving

tar -cvfz [archive.tar.gz] [list_of_files]

[! z -> gzip; j -> bzip2]


Process Management

To monitor the processes via gui

gnome-system-monitor


To list the processes running in current session

ps

[! ps -a for all active processes across sessions; ps a for all processes (including inactive ones) across sessions]


To list the parent proces id and the owner info

ps -f


To list the processes in a tree format

ps af


To list all processes including system ones

ps x


To know the session detail

w


To know users login info

lastlog


To run a process in background

[process/service_name] &


To list the background processes started by users

jobs


kill

To list all the available options with kill command

kill -l


Below are few of the important options

9   -> kill
15 -> terminate
18 -> continue
19 -> stop (temporarily)


To stop a job/process temporarily

kill -19 %[job_id | proces_id]



To resume the stopped job/process

kill -18 %[job_id | process_id]


To make a background process run in the foreground

fg %[job_id]

[! Ctrl+z -> to stop temporarily; bg %[job_id] to take that to background]


To terminate a process

kill %[job_id]
kill [process_id]

[! kill command defaults to option 15, if nothing else is specified]


To force kill a process

kill -9 [process_id]


To kill using the process name

pkill -9 [process_name]


top

To list the running processes

top

[! the display gets refreshed every 3 sec; top -d 1 to refresh the display every 1 sec]


To kill the process based on id

k


To sort top output based on memory utilised

Shift+M


To sort based on CPU usage

Shift+C


To sort based on user

U



-- End of Day 7 --

No comments: