Conventions:
man # the on-line manual with a complete list of options available for each command.
pwd # print working directory: give absolute path from root to current directory. cd # change directory.
cd ~ # takes you to your home directory. cd .. # takes you to the parent directory of the current directory. mkdir # make directory.
rmdir # remove directory. (Note: The directory must be empty to be removed.)
ls # list files in current directory, with "/" for directories, and "*" for executables.
ls -l # gives a long listing, showing permissions, size, date last changed, etc. ls -a # include hidden files (filenames starting with a ".") ls -Fla # do all three options above at once. cp # copies a file, with name either absolute or relative.
rm # removes a file, but not a directory. See rmdir above.
rm -r # removes a directory and recursively everything below the directory. # Useful, powerful, dangerous command!
su; rm -r / # need superuser password and a suicide hot-line mv # move or rename a file or a directory; this can be a dangerous command if you make typo!
more # lists the contents of a file and pauses at each screenful.
cat # concatenates files and prints to the screen.
cat -n filename # adds line numbers. cat file1 file2 > file3 # append file2 to the end of file1 and save as file3. script # records all interactions in a window and saves in a file.
history # lists previous commands by number.
!v # executes the last command that started with the character v !! # executes the last command
Ctrl-c # emergency stop for a process.
Ctrl-d # end of file.
Sample Interactive Session (on Linux):
neal@linux:~> pwd # print current working directory /home/neal neal@linux:~> ssh wagner@elk02.cs.utsa.edu # secure shell to UTSA wagner@elk02.cs.utsa.edu's password: ****** # type password elk02:~> mkdir example # create a new directory elk02:~> ls -F # list current directory contents example/ # (actually, there's lots more junk here) elk02:~> cd example # change to the new directory elk02:~> pwd # print the current path /home/wagner/example elk02:~> vi goodmen.txt # use vi to create new file iNow is the time for all good men # initial "i" is for "insert" to come to the aid of their party. [Esc] ZZ # type "Esc" key, followed by "ZZ" elk02:~> ls -l # long listing total 1 # one file in this directory -rw-r--r-- 1 wagner news 69 Dec 30 17:24 goodmen.txt # 69 chars in file elk02:~> cat -n goodmen.txt # print to terminal with line #s 1 Now is the time for all good men 2 to come to the aid of their party. 3 elk02:~> rm goodment.txt # remove file. Oops, misspelled! rm: cannot remove `goodment.txt': No such file or directory elk02:~> rm goodmen.txt # remove the file. elk02:~> ls -l # check listing total 0 elk02:~> cd .. # back to parent directory elk02:~> rmdir example # remove the directory elk02:~> logout # terminate secure shell connect. Connection to elk02.cs.utsa.edu closed. neal@linux:~> # Ahhh. Back at home!
Redirection of input and output: At the command line, Unix allows redirection operators: < , > , and >>
> filename # directs standard output to "filename" rather than the terminal. >> filename # append standard output to "filename". cat file1 file2 > combinedfile # "combinedfile" is just "file1" followed by "file2" Pipes on the command line: Two commands can be connected with a "pipe" by putting | between them:
ls -l | more # a long listing that lets you look one screen at a time Revision date: 2013-12-20. (Please use ISO 8601, the International Standard Date and Time Notation.) |