Skip to content

Latest commit

 

History

History
94 lines (93 loc) · 8.29 KB

File metadata and controls

94 lines (93 loc) · 8.29 KB

Basics of the POSIX CLI (command line interface for n00bs)

  1. DONT DO THIS: rm -rf / (this means delete everything)
  2. ssh webadmin@1.2.3.4 (gets you into a server)
  3. mkdir hello (make a directory called hello)
  4. cd hello (changes your directory to hello, assumes it has been created)
  5. pwd (prints path)
  6. rm your-filename-here (remove filename (BE CAREFUL!)
  7. rmdir - remove directory, if empty
  8. rm -rf directory/xyz (removes whole directory with stuff in it)
  9. rm *.php (removes all files of that type in one directory)
  10. man your--program-here (shows you manual for that part)
  11. cd .. (jumps you back a directory)
  12. cd ../.. (jumps you back two directories)
  13. cd (jumps you back to the home directory)
  14. cd ./whatever/you/want (relative link with that dot in the front)
  15. cd / (take you to the root directory)
  16. cd /home/your-username-here (!where you are!)
  17. mv /path/goes/here/filename /path/goes/here/your-file-name-2 (mv moves a file)
  18. cp /path/goes/here/filename /path/goes/here/your-file-name-2 (copies file in same folder)
  19. cp -a /path/goes/here/. /path/goes/here/ (copies the contents of an existing folder into a previously defined folder)
  20. try to put a first letter on the line, then use TAB key and it tries to autocomplete - nice!
  21. find -name hosts (get)
  22. sudo (switch user, do xyz...)
  23. /etc/hosts (where the host file lives)
  24. /etc/init/d (the folder usually the daemon to start programs live)
  25. /etc/init.d/sendmail start (starts mail on server)
  26. ~/ (Shortcut to go home directory of a given user)
  27. Control + C (kills the process on the command line)
  28. Command + K (OSX clears Bash cache)
  29. Control + L (clears the terminal window)
  30. gzip PATH-HERE - gzips a file for you, which is what phpmyadmin seems to like
  31. mysql -uUSERNAME -pPASSWORD DATABASENAME < MYDATABASE.sql (imports a DB)
  32. host your-domain-here (shows you how the DNS resolves)
  33. shift+control+v (paste into terminal, OSX)
  34. chmod +x or chmod 777 (execute permission to make scripts happen)
  35. cd ~/.ssh (see if you have ssh keys installed)
  36. ssh-keygen -t rsa -C "youremail@host.com" (installs SSH keys - needed for git transactions and other stuff)
  37. source .your-dot-file-here (this refreshes the file, makes life great)
  38. sudo your-samba-passwd-here -a quickstart (changes samba password, allows websites folder in quickstart to appear in mac os x finder)
  39. ssh your-user-name-here@your-ip-address-here (logs you into an SSH session)
  40. ssh root@192.###.###.### (gives you shell access to a server, will prompt for shell password)
  41. hostname (prints your computer's hostname - Linux)
  42. exit (logs you out of an SSH session)
  43. su - username (switches user to username)
  44. clear (erases output in terminal window)
  45. sudo smbpasswd -a your-name-here (changes your samba password for file transfer between OSes, good for virtual machines)
  46. sudo service smbd restart (restarts samba)
  47. rvm --default use 2.0.0 (forces Mac OSX to permanently use a newer version of Ruby)
  48. rvm --default use rubygems 2.0.03 (forces Mac OSX to permantenly use new rubygems - necessary to run Jekyll/Octopress, probably outdated in 2017 but made sense in 2012)
  49. sudo reboot (restarts your machine)
  50. sudo poweroff (turns off your machine)
  51. scutil --get HostName (prints your computer's hostname - OSX)
  52. scutil --set HostName your-name-hostname-here (changes your computer's hostname - OSX)
  53. df (gives you a readout of the disk space your system has available)
  54. pwd | pbcopy (copies your current path in OSX only)
  55. xcode-select --install (installs command line tools for xcode - only necessary on osx 10.8 and down, comes standard on osx 10.9 and up)
  56. chrome://flags (IN BROWSER WINDOW, NOT COMMAND LINE - you play with chrome's plumbing, like disabling that stupid notifications center that tacked into OSX)
  57. If you install node.js, put it here: /usr/local/bin/npm
  58. npm install -g yo (if you have node.js, this installs yeoman, bower and grunt)
  59. npm install -g generator-webapp (puts scaffolding in for creating webapps)
  60. sudo chown your-user-name-here /usr/local/your/root/path/here (changes ownership of various files via CLI)
  61. pbcopy < ~/.ssh/id_rsa.pub (copies something to your clipboard, so you can paste it like a human being - only in OSX. This example copies your SSH key.)
  62. cat - concatenate the key (for example, cat ~/.ssh/id_rsa.pub ), prints my ssh key
  63. /etc (is a symlink to /private/etc - Mac OSX sets this up natively)
  64. /private/etc/apache2/httpd.conf (where the Mac OSX native apache files live)
  65. wget -mirror $url (replicates site in your local folder - whichever folder you run the command from)
  66. gpasswd -a username-here sudo (adds a user to sudo group, must be root)
  67. adduser username (adds user to ubuntu)
  68. ls -a (shows all files, including hidden ones)
  69. ls -al (shows all the file info)
  70. curl -I https://your-url-here.whatever (gives you the HTTP headers for a given request)
  71. <Return> ~ . (kills an open ssh session)
  72. service mysqld start (starts up the mysql server, assumes mysql is installed on the box)
  73. ls (spits out list of directory view)
  74. scp -r /Users/username-here/desktop/source ssh-username-here@ftp.domain.com:/home/user/public_html/dir/destination (scp securely copies a directory from one place to another - the directory on the left is the SOURCE, the right is the DESTINATION)
  75. pwd | tr -d '\n' | pbcopy (copies command line path in OSX - h/t: bradlanders.com) - make an alias of this so its less crazy next time: alias cpwd="pwd | tr -d '\n' | pbcopy"
  76. cpwd (will copy a path to your clipboard, after you make the alias in the above step - aliases will only work locally - YOUVE BEEN WARNED!)
  77. service httpd start (starts your apache server, assumes apache is installed on the box)
  78. ssh -p #### username-here@server-name-here (connect to a specific port (non-22) on a ssh server)
  79. htpasswd -c /user/your-name-here/domain.com/.htpasswd admin (sets up the encrypted .htpasswd file youll need to password protect your apache-based server - will prompt for password, assumes you have apache 2.x installed on your server)
  80. tar -cvzf youfilename-here-dump.tar.gz /home/your/path/here (tars up a directory for you)
  81. ln -s /path/to/file /path/to/symlink (links file to a path with symlink)
  82. /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print substr($0, index($0, $2))}' (OSX ONLY! - gets you the SSID of the wireless network you are on)
  83. /var/www/html or /usr/local/apache/htdocs (This is where your website should/could live on a linux server. Paths are from the root)
  84. cd "Foldername with a Space" (must use quotes to espace space characters on the command line)
  85. cd volumes (access remote drives - if already mounted, they will be at volumes/drive-name-nere)
  86. ls -a (shows list of files in your directory, including hidden dot files)
  87. openssl req -new -newkey rsa:2048 -nodes -out star_example_com.csr -keyout star_example_com.pem -subj "/C=country-code-here/ST=state-code-here/L=city-here/O=organization-here/OU=organization-dept-here/CN=*.example.com/emailAddress=team@example.com" (openssl command to generate a self-signed certificate and private key, note the CN part of command must match the type of SSL cert you need, single or multi-domain)
  88. sudo easy_install pip (installs pip, package manager for python)
  89. alias custom-name-here="cd /Users/you/some/path/here" (structure for making an aliased path, must be saved into OSX user's .profile file or it will not persist beyond current session)
  90. curl -IL https://your-domain.com/file.jpg (gives you an overview of the connect to download the asset - HTTP1 or 2, CORS, etc)
  91. top (displays all processes currently running on your Mac - note the pid because that's the process number each mac process is assigned by the OS)
  92. ls -F |grep -v / | wc -l (counts the lines in a folder)