Cheat Sheets

From QwikITedia

Jump to: navigation, search

Contents

Grep

Search for a string in a file

$ grep "literal_string" filename

Case Sensitive search

$ grep -i "literal_string" filename

Check for string in multiple files with partial same name

$ grep "string" filenames*

Search a dir and sub dirs

$ grep -r "directoryname" *

Count occurrences in a file

$ grep -c "pattern" filename


Secure Copy(scp)

What is Secure Copy?

Why I use it

Examples

$ scp your_username@remotehost.edu:bighairyfile.txt /some/local/directory 
$ scp bighairyfile.txt your_username@remotehost.edu:/some/remote/directory 
$ scp -r bigdir-locationA your_username@remotehost.edu:/some/remote/directory/bigdir-locationB 
$ scp your_username@host1.com:/some/remote/directory/bighairyfile.txt  your_username@host2.net:/some/remote/directory/
$ scp file1.txt fileB.txt your_username@remotehost.org:~ 

tARCHIVng

Extract a tar file

    tar -xvf file.tar
    tar -xvzf file.tar.gz
    tar -xvjf file.tar.bz2

Archive a set of files

 tar -cvf tarfile.tar /var/log/syslog /var/log/messages

Archive and compress (gzip) a set of files

tar -cvzf file.tar.gz /var/log/syslog /var/log/messages

Archive and compress (bzip2) a set of files

tar -cvjf file.tar.bz2 /var/log/syslog /var/log/messages

Display the content of a tar file

    tar -tvf file.tar
    tar -tvzf file.tar.gz
    tar -tvjf file.tar.bz2

Replace a file in an existing tar file

tar -rvf tarfile.tar filetoreplace

Update a file in an existing tar file

tar -uvf tarfile.tar newfile
Personal tools
Namespaces
Variants
Actions
Richard Esmonde.com
Wiki Navigation
Toolbox