Skip to content

Instantly share code, notes, and snippets.

@mondwan
mondwan / tar_usage.sh
Created March 15, 2015 04:55
Archiving and compressing files in Linux
# Extract files fomr mydir.tar
tar xvf mydir.tar
# Create the archive for file mydir and compress with gzip
tar zcvf mydir.tar.gz mydir
# Create the archive for file mydir and compress with bz2
tar jcvf mydir.tar.bz2 mydir
# Create the archive for file mydir and compress with xz
@mondwan
mondwan / io_redirect
Created March 14, 2015 05:30
Types of io redirection in Linux
# redirect stdout
echo "hello" > a.out
# redirect stderr
echo "hello" 2> a.out
# redirect both of them
echo "hello" > a.out 2>&1
# shortcut
echo "hello" >& a.out
@mondwan
mondwan / command_for_dns.sh
Created March 5, 2015 14:51
Different commands for looking up name server information
# Look up hostname using dns
host linuxfoundation.org
# To look up name server interactively
nslookup linuxfoundation.org
# To look up domain name server information from the name server
dig linuxfoundation.org
@mondwan
mondwan / find_usage.sh
Last active August 29, 2015 14:16
Usage of Bash command find
# Find filename with gcc under folder /usr
find /usr -name gcc
# Find directory based on filename gcc under folder /usr
find /usr -type d -name gcc
# Find file which modified today under current directory
find -type f -mtime 0
# Find file which filesize is zero