bindfs
bindfs - mount --bind in user-space
bindfs [OPTIONS] DIR MOUNT_POINT
Examples
bindfs -o force-user=www-data,force-group=www-data,perms=0550,nonempty /www /var/www
bindfs -o force-user=www-data,force-group=www-data,perms=0770,nonempty /www/data /var/www/data
find
find - search for files in a directory hierarchy
find DIR -type f -iname 'FILE_PATTERN'
Examples
find test -type f -iname 'x*'
find test -type f -iname 'x*' -o -iname 'y*'
find test -type f -iname '*[*' -a -not -iname '*]*'
Convert files recursively
find . -type f -print0 | xargs -0 dos2unix
git
git --fast-version-control
Email Address & Username
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
If using a repo setup in windows and then running git on linux
git config --global core.autocrlf input
Examples
git status
git add .
git commit -am "commit message"
git commit --amend
git gui
grep
grep, egrep, fgrep - print lines that match patterns
grep [OPTION...] PATTERNS [FILE...]
grep [OPTION...] -e PATTERNS ... [FILE...]
grep [OPTION...] -f PATTERN_FILE ... [FILE...]
Examples
grep -rnw '/path/' -e 'TEXT_TO_FIND'
-r or -R is recursive,
-n is line number, and
-w stands for match the whole word.
-l (lower-case L) can be added to just give the file name of matching files.
gzip
gzip, gunzip, zcat - compress or expand files
gzip -stdout --best FILENAME > FILENAME.gz
Examples
gzip -stdout --best partclone.img > partclone.img.gz
ln
ln - make links between files
ln -s TARGET LINK_NAME
Examples
ln -s /media/data/downloads ~/downloads
mount
mount - mount a filesystem
mount [-fnrsvw] [-o OPTION[,OPTION]...] DEVICE|DIR
-o options
-t filesystem type
Examples
mount --type=vfat -o umask=007,uid=0,gid=500 /dev/sda1 /media/fat
mount -t ntfs-3g -o remove_hiberfile /dev/sda1 /media/ntfs
mount -o uid=0,gid=500,umask=007,noatime /dev/sda1 /media/data
mount -t cifs -o username=tim //192.168.0.1/data /mnt/data
rsync
rsync -- a fast, versatile, remote (and local) file-copying tool
rsync [-OPTIONS] SOURCE DESTINATION
(trailing / important when referring to directory contents - see examples)
-r, --recursive recurse into directories
-a, --archive archive mode; equals -rlptgoD (no -H,-A,-X)
-v, --verbose increase verbosity
-i, --itemize-changes output a change-summary for all updates
-p, --perms preserve permissions
-u, --update skip files that are newer on the receiver
--delete delete extraneous files from dest dirs
-l, --links copy symlinks as symlinks
-H, --hard-links preserve hard links
-h, --human-readable output numbers in a human-readable format
--progress show progress during transfer
--exclude=PATTERN exclude files matching PATTERN
-n, --dry-run perform a trial run with no changes made
Examples
Mirror Source to Destination
rsync -raviphl --progress --exclude='.fuse*' --delete /media/H/backups/ /media/O/backups/
Update Destination from Source
rsync -raviphl --progress --exclude='.fuse*' /media/N/backups/ /media/H/backups/
tar
tar - manual page for tar
tar [OPTION...] [FILENAME]...
Examples
backup
tar -cpvf home.tar /home
tar -cpvzf home.tar.gz /home
tar --exclude '/home/tim' -cpvzf backup.tar.gz /home
find test -type f -iname 'x*' | tar -cpvzf test.tar.gz -T -
find test -type f -iname 'x*' -o -iname 'y*' | tar -cpvzf test.tar.gz -T -
find test -type f -iname '*[*' -a -not -iname '*]*' | tar -cpvzf test.tar.gz -T -
tar -cpvzf - /home | openssl aes-256-ecb -out backup.tar.gz.aes
tar -cpvzf - /home | gpg --encrypt --output=backup.tar.gz.gpg
restore
tar -xpvf backup.tar
tar -xpvzf backup.tar.gz
openssl aes-256-ecb -d -in backup.tar.gz.aes|tar xpvzf -
gpg --decrypt backup.tar.gz.gpg|tar xpvzf -
list contents
tar -tvf backup.tar.gz
taskset
taskset - retrieve or set a process's CPU affinity
taskset [options] mask command [arg]...
taskset [options] -p [mask] pid
Examples
get cpu affinity
taskset -cp PID
set cpu affinity
taskset -cp 1 PID
taskset -cp 1,2 PID
taskset -cp 0-3 PID
start process and set cpu affinity
taskset -c 1 COMMAND
taskset -c 1,2 COMMAND
taskset -c 0-3 COMMAND
uuid
uuid - Universally Unique Identifier Command-Line Tool
uuid [-v VERSION] [-m] [-n COUNT] [-1] [-F FORMAT] [-o FILENAME] [NAMESPACE_NAME]
uuid -d [-r] [-o FILENAME] UUID
Examples
uuid -v4
zip
zip - package and compress (archive) files
zip backup.zip FILENAME
zip backup.zip FILENAME1 FILENAME2
zip -r backup.zip DIRNAME
zip -r backup.zip DIRNAME1 DIRNAME2
Examples
zip backup.zip .bashrc
zip backup.zip .bashrc .bash_aliases
zip -r backup.zip /home
zip -r backup.zip /home/tim /home/tux
find test -type f -iname 'x*' | zip backup.zip -@
find test -type f -iname 'x*' -o -iname 'y*' | zip backup.zip -@