Conventions:
man # the on-line manual with a complete list of options available for each command.
pwd # print working directory: tells absolute path from root to where you currently are in the file system. 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 the current directory in a column format, with "/" after directories, and "*" after executable files.
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 filel file2 > file3 # append file2 to the end of filel and save as file3. script # records all interactions in a window and saves in a file.
history # lists previous commands by number.
!v # exectues 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 # current directory at home
/home/neal
neal@linux:~> ssh wagner@gateway19.cs.utsa.edu # secure shell to UTSA
wagner@gateway19.cs.utsa.edu's password:******** # type password
[wagner@gateway19 ~]$ mkdir example # create a new directory
[wagner@gateway19 ~]$ ls -F # list current directory contents
example/ # actually, there's more junk here
[wagner@gateway19 ~]$ cd example # change to the new directory
[wagner@gateway19 ~/example]$ pwd # print the current path
/home/wagner/example
[wagner@gateway19 ~/example]$ 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"
[wagner@gateway19 ~/example]$ ls -l # long listing
total 1 # 1 file in this directory
-rw-r--r-- 1 wagner news 69 Dec 30 17:24 goodmen.txt # 69 chars in file
[wagner@gateway19 ~/example]$ 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
[wagner@gateway19 ~/example]$ rm goodment.txt # remove file. Oops, misspelled!
rm: cannot remove `goodment.txt': No such file or directory
[wagner@gateway19 ~/example]$ rm goodmen.txt # remove the file.
[wagner@gateway19 ~/example]$ ls -l # check listing
total 0
[wagner@gateway19 ~/example]$ cd .. # back to parent directory
[wagner@gateway19 ~]$ rmdir example # remove the directory
[wagner@gateway19 ~]$ logout # terminate secure shell connect.
Connection to gateway19.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-01-12. (Please use ISO 8601, the International Standard Date and Time Notation.) | |||||