If you have any questions, please contact Michelle, Kirsten or Dan. host (find ip address and email for a web domain) mkdir (make directory) cd (change directory) (cd ~ to get to home directory) ls (list) touch (make file) rm (remove—careful this is irreversible) rm - r (remove a directory) -a (dash is the ‘option’, ‘a’ is the argument) means list hidden system files cd .. (move back up one level in the file system) cd/users/everonthego/Desktop (type out full path) cd .. / (relative path command when both files share a parent directory) no space between /file pwd (show present working directory) -i (toggles interactive mode to confirm deletion or other action) cd ~ (return to User folder) mv (move, then enter path to new location, can also be used to rename a file) man (show usage options for a command, example: man ls, type ‘q’ when finished) To abort a command: ‘control c’ (looks like ^c) I also picked up a few tutorials and tips along the way. This, about Linux (which I believe is similar?) Important facts about file names 1. File names that begin with a period character are hidden. This only means that ls will not list them unless you say ls -a. When your account was created, several hidden files were placed in your home directory to configure things for your account. Later on we will take a closer look at some of these files to see how you can customize your environment. In addition, some applications will place their configuration and settings files in your home directory as hidden files. 2. File names in Linux, like Unix, are case sensitive. The file names "File1" and "file1" refer to different files. 3. Linux has no concept of a "file extension" like legacy operating systems. You may name files any way you like. However, while Linux itself does not care about file extensions, many application programs do. 4. Though Linux supports long file names which may contain embedded spaces and punctuation characters, limit the punctuation characters to period, dash, and underscore. Most importantly, do not embed spaces in file names. If you want to represent spaces between words in a file name, use underscore characters. You will thank yourself later. A tutorial that I found via TigerTech and is useful: (Linux, but still on the bash shell) Learning The Shell A beginner tutorial by MacTuts: Navigating the Terminal: A Gentle Introduction A YouTube tutorial: (goes by fast but has a lot of stuff, no part two, even though it says there is one): Terminal Tutorial Part 1: Commands and Concepts We also had a conversation about the ll command early in the programming internship. It's here in the Programming Internship BaseCamp: Enable the ll command Logging in as root was covered there as well: Enable the Root User the general syntax of command line statements is commandname -optionabbreviation optionvalue -asmanyoptionabbrevisationsasyouwant -optionvalue --optionwholename optionvalue objectsToCommandUpon It gets complicated. example zip -r zipfile.zip --exclude pathToExclude pathToFilesDirectoriesToInclude Kirsten Bolda said: ↑ -i (toggles interactive mode to confirm deletion or other action) The letters of options vary by command. -i can mean different things for different commands, or if ti doesn't that would be a miracle. Kirsten Bolda said: ↑ cd ~ (return to User folder) usually referred to as home directory. If you want to represent spaces between words in a file name, use underscore characters. You will thank yourself later. Better advice never given. ADD: Text editing on unix. Take a look at the two files attached*, textWindow.txt and textUnix.txt. Open the files. Do you see the difference? Answer: difference is not visible, but one file works when it is run on unix and other doesn't Why? * I need to provide the files How text edit: use nano or vi. lists directory and file sizes in order of size du -m -h -s -c -- * | sort -h ; find a file find . -iname 'filename' (can use * as wildcard) find occurrences of a string files grep -H -r 'stringtofind' pathtosearch Search files for string, and replace the string with another find . -type f -exec sed -i 's/stringtofind/string to put when otherone is found /g' {} + warning: if string includes $, / or just about anything other than numbers and letters, this gets absurdly tricky. dump a database mysqldump -u username -p databasename > databasename.sql To load a database from a dump mysql -u username -p databasename < dumpfile On plesk: instead of -u username -p, use -u admin -p`cat /etc/psa/.psa.shadow` it always works. This helpful Pull files from another server wget ftp://ftpaccountname:ftppassword@ftpaddressofotherservr/path-to-pull wget can be made recursive, but using -m but instead of doing that, it is better to zip all the stuff all files and directories you need to pull, then pull the one file, unzip. Much faster and simpler Check how much disk is used and available df setting up aliases (I need to elaborate) setting up symbolic links (will elaborate in conjunction with aliases)
A very useful command: cat filename (where filename is the name of the file in question) Use cd directoryname (change directory) And cd .. (move back up one directory) And ll (two lower case letter Ls, list contents of directory) And cat filename To move around the entire server and examine its contents. For more on this command: (link) Example of this command in action:
What a great way to locate a file, or even a particular expression, inside a directory. In my case, I was in search of a function inside the clone of Holly's system. The command to get that done is called grep, and the syntax goes like this: grep (the command) -H (causes the file name to be printed) r (does a recursive search) then 'put the string for the file in question here' . (the period starts the search at the file you are in ) For my function search I first listed (ll) and changed directories (cd) until I was in the cloned system directory, then entered: grep -Hr 'function add_dl_links' . It returned: ./pageparts/000-common/001-dansoft-emp.php:function add_dl_links($page_content){ //return $page_content; ./zDansoft/pageparts/000-common/001-dansoft-emp.php:function add_dl_links($page_content){ //return $page_content; ./0000000-archive/howtothinksideways.com/20080414/pageparts/000-common/001-dansoft-emp.php:function add_dl_links($page_content){ //return $page_content; So that went well. Some problems to look out for: Zip files or large .sql files in the search zone will fill the screen with useless information. There are ways to exclude those, but they are a lot of trouble to set up. Apostrophes and other characters that have to be escaped in the search string will make the search process more difficult to set up
clear (clears all previous commands and files out of the window) unzip example (uncompresses the file, it is not necessary to include the .zip extension of the file. Also can be used to unzip a file on your computer. Just drag and drop the file you want to unzip into the command line window after entering unzip, then hit enter)
cat can fill your screen with craziness but it does not run programs, making it a safe stick for poking at things.
dirsize (Lists all the files, then directories in the present working directory, followed by the size and number of files in the directory)
On OSX, try this to see super clear: cat /var/log/auth.log Lots of stuff comes onto screen. clear now try scrolling up. So much stuff!!! what if you want run a command and have nothing in terminal window except the output of that command? Click on the edit menu and select "clear to start" Now try scrolling up... no stuff!! niiiiiiiiiiiiiiiiiiiiiiiiiiiiiice. That is super clear on a MAC. Other platforms I don't know what they do, but my heart goes out to them.
dirsize is a shell script I put into your ~/bin directory. You can see it by cd ~/bin ll The reason it runs no matter which directory you are in when you type is that these lines are in your ~/.bashrc file at the end PATH=$PATH:$HOME/bin:~/bin/: export PATH
cp (copy) Example: Navigate to source directory Check dirsize: Enter cp (copy) * (everything in the present directory) ../exampledirectory (target directory, in this case a sibling directory, one step up the tree and back down) Test by navigating to target directory and checking dirsize against source directory dirsize
I see there are some of the other commands you made in there too: That's pretty cool. OMG! It just never stops. It's like I'm in the Matrix! Ah, finally done. Just a section of the whole thing: I couldn't get the result you had though. I could clear it all, but not with this: 'Clear scrollback' seemed to lock up Terminal, and Clear took me back to a completely clear screen.
another sample of the same deal. This file contains a video (2:29 in duration) of cat -n rsync_mondoboss.log running on my screen, plus the file rsync_mondoboss.log. I picked the number 427,000 out of the air and looked to see what is there and if that is a stable result. If you get a chance to take in this video, just for kicks, can you cat the file to your screen and confirm that line 628734 contains this string exactly? 2016/10/31 09:45:49 [6664] >f+++++++ www.devserver-002.info/htdocs/testareas/array/css/random.gradients.all.rights.reserved.css If you find that string, does it have a space at the end of it? I just think it is so amazing that we have this level of precision at our disposal on this scale
I'm confused about the 'cp' command because I am able to copy a file from one directory to another, but when I try to do the same with with a directory the Terminal will sit and think about it for a moment, but then respond that since this is a directory it is not copied. Everything I look up about Terminal and Linux/Unix (Example: cp command in Linux/Unix @ Rapid Tables ) indicates that copying a directory is no different than copying a file, but apparently that is not the case, because the command: Code: cp monstra-3.0.4 ../Practice-cp generates the complaint that a directory will not be copied. I can't seem to find anything that shows me what I am doing wrong, even though I bet it's obvious to anyone experienced with this stuff. The reason I am doing this exercise is so that I can do some rearrangement of these directories on my server. Moving them around with FileZilla is cumbersome and inefficient, and besides copying directories seems like a good skill to learn.
Here's a shortcut I just learned that is saving me a bunch of typing and even copying and pasting. When you want to change directory, instead of typing out the whole directory name, or copy/pasting it in, just hit the first letter (or first few depending on whether other directories share the first initials) and then the tab key. The command line will fill in the rest of the name in the directory up to the next non unique character. An example makes this easier to explain. Let's say I'm at kbdc: And I want to head on over to the dbadminxCCdFyeHFYZJGReE/ directory. Sure, I can copy/paste that bad boy into the command line but, how about I just type cd dba and hit tab to let the computer do it for me? (edited to add: technically I could just have typed 'db' and that would be enough for Terminal to fill in the rest of the directory name.)
Changing a password: Once you are logged in, type: Code: passwd You will be prompted for your new password:
Moving directories: from this post: https://legacy-systems.biz/index.php?threads/i-think-you-will-want-to-see-this.46/page-2#post-274 Code version of mv: Code: mv directoryName path/to/new/directoryName Moving files is accomplished in the same way as moving a directory. Reference: https://legacy-systems.biz/index.php?threads/i-think-you-will-want-to-see-this.46/page-3#post-290