- DONT DO THIS:
rm -rf /(this means delete everything) ssh webadmin@1.2.3.4(gets you into a server)mkdir hello(make a directory called hello)cd hello(changes your directory to hello, assumes it has been created)pwd(prints path)rm your-filename-here(remove filename (BE CAREFUL!)rmdir- remove directory, if emptyrm -rf directory/xyz(removes whole directory with stuff in it)rm *.php(removes all files of that type in one directory)man your--program-here(shows you manual for that part)cd ..(jumps you back a directory)cd ../..(jumps you back two directories)cd(jumps you back to the home directory)cd ./whatever/you/want(relative link with that dot in the front)cd /(take you to the root directory)cd /home/your-username-here(!where you are!)mv /path/goes/here/filename /path/goes/here/your-file-name-2(mv moves a file)cp /path/goes/here/filename /path/goes/here/your-file-name-2(copies file in same folder)cp -a /path/goes/here/. /path/goes/here/(copies the contents of an existing folder into a previously defined folder)- try to put a first letter on the line, then use TAB key and it tries to autocomplete - nice!
find -name hosts(get)sudo(switch user, do xyz...)/etc/hosts(where the host file lives)/etc/init/d(the folder usually the daemon to start programs live)/etc/init.d/sendmail start(starts mail on server)~/(Shortcut to go home directory of a given user)Control + C(kills the process on the command line)Command + K(OSX clears Bash cache)Control + L(clears the terminal window)gzip PATH-HERE- gzips a file for you, which is what phpmyadmin seems to likemysql -uUSERNAME -pPASSWORD DATABASENAME < MYDATABASE.sql(imports a DB)host your-domain-here(shows you how the DNS resolves)shift+control+v(paste into terminal, OSX)chmod +x or chmod 777(execute permission to make scripts happen)cd ~/.ssh(see if you have ssh keys installed)ssh-keygen -t rsa -C "youremail@host.com"(installs SSH keys - needed for git transactions and other stuff)source .your-dot-file-here(this refreshes the file, makes life great)sudo your-samba-passwd-here -a quickstart(changes samba password, allows websites folder in quickstart to appear in mac os x finder)ssh your-user-name-here@your-ip-address-here(logs you into an SSH session)ssh root@192.###.###.###(gives you shell access to a server, will prompt for shell password)hostname(prints your computer's hostname - Linux)exit(logs you out of an SSH session)su - username(switches user to username)clear(erases output in terminal window)sudo smbpasswd -a your-name-here(changes your samba password for file transfer between OSes, good for virtual machines)sudo service smbd restart(restarts samba)rvm --default use 2.0.0(forces Mac OSX to permanently use a newer version of Ruby)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)sudo reboot(restarts your machine)sudo poweroff(turns off your machine)scutil --get HostName(prints your computer's hostname - OSX)scutil --set HostName your-name-hostname-here(changes your computer's hostname - OSX)df(gives you a readout of the disk space your system has available)pwd | pbcopy(copies your current path in OSX only)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)chrome://flags(IN BROWSER WINDOW, NOT COMMAND LINE - you play with chrome's plumbing, like disabling that stupid notifications center that tacked into OSX)- If you install node.js, put it here:
/usr/local/bin/npm npm install -g yo(if you have node.js, this installs yeoman, bower and grunt)npm install -g generator-webapp(puts scaffolding in for creating webapps)sudo chown your-user-name-here /usr/local/your/root/path/here(changes ownership of various files via CLI)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.)cat- concatenate the key (for example, cat ~/.ssh/id_rsa.pub ), prints my ssh key/etc(is a symlink to /private/etc - Mac OSX sets this up natively)/private/etc/apache2/httpd.conf(where the Mac OSX native apache files live)wget -mirror $url(replicates site in your local folder - whichever folder you run the command from)gpasswd -a username-here sudo(adds a user to sudo group, must beroot)adduser username(adds user to ubuntu)ls -a(shows all files, including hidden ones)ls -al(shows all the file info)curl -I https://your-url-here.whatever(gives you the HTTP headers for a given request)<Return> ~ .(kills an open ssh session)service mysqld start(starts up the mysql server, assumes mysql is installed on the box)ls(spits out list of directory view)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)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"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!)service httpd start(starts your apache server, assumes apache is installed on the box)ssh -p #### username-here@server-name-here(connect to a specific port (non-22) on a ssh server)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)tar -cvzf youfilename-here-dump.tar.gz /home/your/path/here(tars up a directory for you)ln -s /path/to/file /path/to/symlink(links file to a path with symlink)/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)/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)cd "Foldername with a Space"(must use quotes to espace space characters on the command line)cd volumes(access remote drives - if already mounted, they will be at volumes/drive-name-nere)ls -a(shows list of files in your directory, including hidden dot files)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)sudo easy_install pip(installs pip, package manager for python)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)curl -IL https://your-domain.com/file.jpg(gives you an overview of the connect to download the asset - HTTP1 or 2, CORS, etc)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)ls -F |grep -v / | wc -l(counts the lines in a folder)