~ - Home Directory
. - Current Directory
.. - Enclosing Directory
/ - Root Directory
$ cd ~/Dropbox/code
$ cd ..
$ pwd
/Users/rd/Dropbox
$ ls
$ ls -la
$ la
$ ls -tla
$ mkdir projects
$ mkdir -v code
$ mkdir -p code/sinatra-app/public code/sinatra-app/views
$ touch notes.md
$ echo "# Using the OS X Command Line" > cli.md
$ ls --help
ls: illegal option -- -
usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]
$ man --help
$ man ls
$ info ls
$ mv projects old-projects
$ cp app.rb old-projects/
$ cp -R old-projects really-old-projects
$ rsync -r --progress /folder/to/copy /destination/folder
$ rm junk.txt
$ rm -rf really-old-projects
These two apps allow you to install almost anything from the command line.
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew install caskroom/cask/brew-cask
$ brew install wget
$ brew cask install paintbrush
$ brew cask install --appdir="/Applications" vlc
$ brew search wget
$ brew info p7zip
$ echo
$ grep
$ la | grep .txt
$ tar
$ cat
$ head
$ tail
$ brew
$ tree
$ which
$ whoami
$ curl
$ nano
$ say 'Hello'
Add #!/usr/bin/env ruby
to top of the file.
$ chmod +x food_trucks.rb
$ ./food_trucks.rb
/usr/local/bin
should be first when using homebrew!:export PATH=/usr/local/bin:$PATH
- Always append to the end of the $PATH
- Postres.app:
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.3/bin
$ printenv
$ echo $PATH
$ brew doctor
$ nano ~/.zshrc
$ nano ~/.bashrc
$ which ruby
$ chruby
ruby-1.9.3-p545
ruby-2.0.0-p451
ruby-2.0.0-p594
ruby-2.1.2
ruby-2.1.3
* ruby-2.1.4
ruby-2.1.5
$ chruby ruby-2.1.5
$ echo "ruby-2.1.5" > ~/.ruby-version
$ ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/bin/subl
$ which atom
/usr/local/bin/atom
$ la /usr/local/bin/atom
$ cd ~/Dropbox/code/launchvotes
$ atom .
$ subl .
$ ps aux | grep safari
$ kill 123
$ tar -zxvf plans_to_take_over_the_wolrd.tar.gz
$ tar -xvjf area51_research_documents.tar.gz2
zip -r archive_name.zip folder_to_compress
$ tar -tf filename.tar.gz
slooooooow
$ grep -rn collection_select ~/Dropbox/code
faster
$ brew install ack
$ ack --bar
$ ack collection_select ~/Dropbox/code
way fast
$ brew install the_silver_searcher
$ ag collection_select ~/Dropbox/code
$ ag --list-file-types
$ ag "HTTP POST" --markdown
$ find ~ -iname "time.rb"
$ find . -type f -name "test.log"
$ find . -type f -newermt 2017-06-21 ! -newermt 2017-06-22
$ find ~ -iname "*.log" -exec rm {} \;
$ find ~ -size +500000 -print
$ df -H
$ cat ~/.ssh/id_rsa.pub | pbcopy
brew install nmap
sudo nmap -sP 192.168.1.0/24
ssh username@ip_address
ssh [email protected]
scp source destination
scp ~/install.sh user@ip_address:/Users/rd/install.sh
scp user@ip_address:/Users/rd/Downloads/raspbian.img ~
ssh [email protected] tail -f /home/ubuntu/shared/logs/production.log
sudo scutil --set HostName your-new-hostname
Scale is from +10 (very nice) to -10 (not nice)
ps aux | grep chrome
renice -n -5 -p pid
system_profiler SPUSBDataType
say 'Thank you'
This is pretty nice, I didn't know about
pbcopy
andsay
, they seem quite useful for cronjob pranks 😏A quick note regarding clean-up-logfiles-in-your-home-directory,
find
has a-delete
flag: