1 / 16

Further Command line…

Further Command line…. Nic Bertrand. CEH IT Support, GRID & Bioinformatics. Content. Compression, archiving utilities Input/Output/Error redirection Pipes Who is using that file? (lsof, fuser). Compression/Uncompression.

frayne
Download Presentation

Further Command line…

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Further Command line… Nic Bertrand CEH IT Support, GRID & Bioinformatics

  2. Content • Compression, archiving utilities • Input/Output/Error redirection • Pipes • Who is using that file? (lsof, fuser)

  3. Compression/Uncompression • Linux supports the compression of a wide range of archiving formats:.zip, .tar, .gz, .Z, .bz2

  4. Tar Most common use: Uncompress an archive: Tar xvf archive.tar Tar xvzf archive.tar.gz Tar xvjf archive.tar.bz2 Check an archive: Tar tf archive.tar Tar tzf archive.tar.gz

  5. tar -- tape Archiving Utility • Creating an archive: Tar cvf archive.tar *.txt Built-in gzip/bzp2 function: tar cvzf archive.tar.gz *.txt tar cvjf archive.tar.bz2 *.txt

  6. Gotchas with tar… • never use absolute paths when creating an archive... e.g. don’t do: tar cvf home_archive.tar /home • Check the content of a tar file using tar tf

  7. Moving file tree using tar • cd /sourcedirtar cf - . | (cd /destdir && tar xpf -)

  8. gzip • Compressing: gzip file-> file.gz.gz is compressed • Uncompressing:gzip -d file.gz or gunzip file.gz

  9. Other compression formats Software Common extension compress/uncompress .Z zip/unzip .zip bzip2/bunzip2 .bz2 Warnings: Linux does not support windows self-extractable .exe zip archives Bio-Linux does not support ARJ archives “out of the box”

  10. Checking file types: file • Used to determine the file typeexamples:binary, ASCII text, GNU tar format… Examples: feeding an binary ‘text’ file (word document) into clustalw or blastall will not work…

  11. Input/output redirection • write standard output to file Myprog > output.txt • Append standard output to file Myprog >> output.txt • Standard error to standard output Myprog >outputfile 2>&1

  12. More I/O redirection • Normal mode: • myprog > output.txt (send stdout to file) • myprog 2> error.txt (send stderr to file) • myprog > allout.txt 2>&1 (send stdout and stderr to file) • myprog < inputfile (take stdin from file) • myprog 2> /dev/null (chuck stderr into oblivion!) • Append: • myprog >> output.txt (send stdout to end of file) • myprog 2>> error.log (send stderr to end of file) • myprog >> allout 2>&1 (send stdout and stderr to end of file) • myprog <<x (take stdin until "x" occurs) • Pipes: • myprog | myprog2 (pipe stdout of myprog to stdin of myprog2) • myprog 2>&1 | myprog2 (pipe stdout and stderr of myprog to myprog2)

  13. Getting info on what/who is using a file/device/socket • Crucial info if: You want to unmount device, partition and and you get a frustrating ‘umount: device is busy’ LSOF and FUSER are useful tools

  14. lsof: list open files • lsof /mnt/cdromwhat/who is using the cdrom? • lsof –i :505 what is using TCP port 505?

  15. fuser: identify processes using files or sockets • man fuser • list all process accessing port: fuser ssh/tcp • fuser -mk /home/user1 lists all processes using /home/user1 and terminates them!

  16. Exercises 1. list processes that access the /var partition 2. list processes that use the ssh port a. using fuser b. using lsof3. 3. Launch Artemis. Consult the man page for fuser and figure out a way to send a kill signal to all process that use /usr/software What happens? 4. list all manual pages relevant to password 5. email the man passwd page to your email account 6. cd ~manager/examples/further_cli/tar/Compress all the blast reports (.blastp) files into a tar.gz file 7. cd ../compressedexpand compressed.tar file in current directory 8. Compress/gzip all .prot files. What sort of compression ratio do you get? Can you alter/improve this?

More Related