Linux – Compress Commands (Faq)

1. compress a file using zip – used to unzip oracle on linux software

zip
package and compress (archive) files

#compress
[sdbt ~]$ zip alpha.zip alphabets.txt
adding: alphabets.txt (deflated 9%)

[sdbt ~]$ ls *.zip
alpha.zip

[sdbt ~]$ mv alpha.zip dir1/

[sdbt ~]$ ls dir1/
alpha.zip file1.txt file2.txt filexpand.txt

#extract
[sdbt ~]$ unzip alpha.zip
Archive: alpha.zip inflating: alphabets.txt

2. gzip – gzip reduces the file of compressed files( frequently used to compress the oracle exp and datapump dump files)

[sdbt ~]$ gzip alphabets.txt

[sdbt ~]$ echo *.gz
alphabets.dmp.gz

[sdbt ~]$ gunzip alphabets.dmp.gz

[sdbt ~]$ gzip -d alphabets.dmp.gz

3. tar – tar compresses many files together into a single tape or disk archive

Mostly used to compress a folder( can be used to copy ORACLE_HOME to another server)

and compress a directory.

[sdbt ~]$ tar -cvf file.tar file* #compress tar and gzip

[sdbt ~]$ tar -tvf file.tar #list the compressed files

[sdbt ~]$ tar -xvf file.tar #extract the compress files

(tar with gzip )

[sdbt ~]$ tar -cvzf file.tar.gz file* #compress tar and gzip

[sdbt ~]$ tar -tvzf file.tar.gz #list the compressed files

[sdbt ~]$ tar -xvzf file.tar.gz #extract the compress files

5. jobs – Displays all running jobs.

[sdbt ~]$ jobs

[sdbt ~]$ jobs -l

6. nohup – Displays the log in nohup.out file

& -> is used to execute the command in background.
nohup -> will store the log information

[sdbt ~]$ nohup cp scr.tar.gz /home/jlaxmi/Desktop/ &

[1] 19510
nohup: ignoring input and appending output to `nohup.out’

[1]+ Done nohup cp scr.tar.gz /home/jlaxmi/Desktop/

7. To schedule a shellscript

[sdbt ~]$ crontab –e #To add Schedule a job
crontab: installing new crontab

[sdbt ~]$ crontab –l #To list out the scheduled job in cron
10 * 12 7 4 who |wc -l >>/home/sdbt/report.txt

[sdbt ~]$ crontab –r #To remove all job in crontab.

$ crontab -e

50 5 5,15,25 * 6 . check.sh #run script 5.50 am at 5,15,25 of month and every saturday.

*/10 11-12 11 7 3 who |wc -l >>/home/jlaxmi/report.txt
#update every 10 minutes once how may user work in.

* * * * * -> 5 stars
first * -> minute(0-59)
*/5 -> runs every 5 minutes
0,15,30,45 -> runs every 0th, 15th, 30th and 45th Minutes.
second * -> hour(0-23)
third * -> Day of the months (1-31)
fourth * -> month (1-12)
fifth * -> Day of the week(0-6)