Useful UNIX commands to remember

history
get history of commands

history | grep “sudo”
find all history of commands that has sudo in it

history > commands.txt
output the history to a text file

increase scrollback buffer in OS X

  1. Edit .bash_profile 
  2. Add HISTFILESIZE=2000

 

Copy files recursively keeping directories
cp . -b –parent /usbdrive

Find files by certain size and copy them
find . -size -4gb -exec cp -b –parent ‘{}’ /downloads \;

restart shell

  • . .bash_profile
  • sh .bash_profile

 

Rsync only certain file size
rsync -rv –max-size=1.5m root@tss01:/tmp/dm

Prevent SSH disconnect
edit /etc/ssh/ssh_config
ServerAliveInterval 100

Copy files without overwrite and typing Y over and over again
yes n | cp -R -h -i /dirone/* /dirtwo 

Creating alias shortcuts
alias browse=’nautilus’
alias gohere=’cd /gohere’

You can save shorts to your .bash_profile file. 

Leave a Reply