cd ~ # takes you to your home directory. cd .. # takes you to the parent directory of the current directory.
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.
# Useful, powerful, dangerous command!
su; rm -r / # need superuser password and a suicide hot-line
cat -n filename # adds line numbers. cat file1 file2 > file3 # append file2 to the end of file1 and save as file3.
!v # executes the last command that started with the character v !! # executes the last command
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!
> 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"
ls -l | more # a long listing that lets you look one screen at a time | |||||