Linux Command Recap


whoamii: To find out who I'm logged in as use whomai
pwd: To figure out what directory I'm in use pwd -- present working directory
cd: To change to another directory cd -- change directory
Note that cd by itself will return you to your home directory.
ls: To list the contents of my directory use ls -- list
ls -l: To see a long listing use ll -- long list (or ll if it is set up)
more: To see the contents of a text file use more filename. Type the space key to see the next page, or a q to quit the command.
cp: To copy a file named file1 to a new file named filed2, use cp file1 file2
rm: To remove (delete) a file named trash use rm trash
mkdir: To make a new directory named dirname, use mkidr dirname (e.g. mkdir public_html)
chmod: To set permissions for a web page file named filename, use chmod 644 filename (e.g. chmod 644 index.html)
To set permissions for a web page directory named dirname, use chmod 711 dirname (e.g. chmod 711 public_html)
emacs: To start the emacs editor in the background on a file named filename, use emacs filename & (e.g. emacs index.html &)
npasswd: To change your password use npasswd and wade through the instructions :-)
rmdir: To remove a directory, use rmdir dirname. The directory must be empty.
mv: To move a file, use mv {oldloc/}filename {newloc/}filename (the curly brackets mean this is optional). There are lots of variations.
To simply rename file1 to file2, use mv file1 file2.
Or if, for instance, you accidentally put index.html in your home directory and you are looking in your home directory, you can move it from the home directory
to public_html with mv index.html public_html/.
or, if you are looking in public_html try
mv ../index.html . The ".." means move up one directory level from where I am now". The "." means "use the same filename."
grep: This allows you to search for a particular pattern from the designated input. To find all the files that contain the word the you could use grep the *; to find all the files that contain any "the" with any capitalization, you would use grep -i the *.
man: To see the exact instructions for a command use man commandname (e.g. man more). Type the space key to see the next page, or a q to quit the command.
clear: clear will clear the terminal window for you.
Ctrl-c: Ctrl-c at the command line level will terminate a command that is running (such as an emacs command which you did not end with an &). This is read as "control c" and you do it by holding down the Ctrl key and typing a "c".

Shortcuts:
* Use the Tab to complete filenames or pathnames once you have started the command (e.g. cd pu then the Tab key to fill out the "blic_html")
* Use the arrow keys when you are in the terminal to scroll up to previous commands.
* Once you are familiar with emacs check the shortcut list to the right of the commands in the pull-down menu. For instance ctrl-x ctrl-s will save the buffer for you (hold down the Ctrl key and type "x" and then "s").

Tips:
* If the backspace looks funny type the command stty sane
* emacs often works poorly with the keyboard commands (e.g. block deletes). Use the menu commands emacs provides to work with block text.
* Pathnames matter in Linux. If things are working wrong, check your path.
* You can make tabs in some navigators (e.g. Mozilla) by holding down the Ctrl key and typing t (commonly referred to as "ctrl-t"). This makes it easy to flip back and forth between various web pages.
* To view the source of a web page that is in a frame (has a separate "band" of commands along one edge) right-click in the main web page (not over an image), select This Frame then Show Only This Frame. Now you can right-click and select View Page Source. (Back will return you to the regular display.)
* Linux allows a "pipe" ("|" -- upper case \) function, which allows input from one command to be "piped" (sent as input) to another command. For instance, if you are long-listing more files than will fit on one screenful (page), you can use ls -l | more.
* To forward your CS department email to your own personal address: in your home directory, create a text file named exactly .forward containing exactly the name of the e-address to which you want your email forwarded.

Nick's list of "Commands I wish I had learned earlier" (I suggest you look these up in the online manual before using them):
* du to look at disc usage (for quota problems)
* rm -r instead of rmdir
* find helps you find files
* ssh lets you log into other computers (for instance, log into the CS department from home -- notes for this in the FAQ)
* top shows what's running most actively on your computer
* cd - returns you to the previous directory
Other good ones to know include: ping, send, mail, and scp (lets you secure copy files between machines, e.g. "scp username@host.cs.colostate.edu:~/dirnname/filename ." or "scp filename uname@host...edu:/~/dirname/filename)).