In general it is a good idea to create a .trash directory and to alias rm as "mv !^ /home/user_name/.trash". To empty the .trash directory you need to reset the alias of rm to rm. Other simpler options are aliasing cp, mv, rm by their -i options and safety features in the login files, such as "set noclobber" in .cshrc.
logname | |
who [am I] | |
quota -v | |
write | write username terminal |
mesg | |
script |
|
Exercise
Login to the computer of your neighbor and write to him/her.
man | examples: man man; man -k calendar; man 5 man |
cal | |
calendar | (a reminder service) |
look | look word (dictionary look-up) |
ispell | a spell check (an elaborate version of "spell") |
date |
. | The current directory | ||||||||||||||||
.. | The next higher directory | ||||||||||||||||
cd |
pwd |
| mkdir |
mkdir -p -m "a=r" this_level/next_level/last_level
| rmdir |
rmdir [-i] -p this_level/next_level/last_level
| cp |
| mv |
| rm |
| ln |
| dircmp |
dircmp dir1 dir2
| |
Exercises
Do the following things using as few commands as possible! (Write down the commands you use.) Create one directory called abe with a subdirectory homer that contains the files bart, lisa and maggie. Create another directory called marge that contains files that are called bart, lisa and maggie and that are linked to homer's files. Write a sentence into each of the three files (use "echo" to do this). Create another directory called simpson and move everything else there. Compare marge and homer to see whether their files are identical. Remove everything except an empty directory "marge".
ls |
file | (shows file type (sometimes))
| wc | (counts lines words characters)
| which | (finds programs according to paths and aliases)
| find |
| |
Exercises
a) Try all of the options for ls mentioned above. When were your
last files accessed/changed? Execute "ls -lut" then "ls -R" and then one
miute later "ls -lut" again: what do you notice?
b) Which of your files in one directory contains the most characters?
c) What is the full path name of "ls"?
d) List all files in any subdirectory under your current directory
that have an "html" extension using "ls". Do the same using "find".
e) Do a long list of the current directory.
f) Compare (find . -name "*d*" -print) and (ls *d*).
a) Find all files in /etc that have a "d" extension.
b) Find all files in the current directory that have an extension.
c) Find all files in the current directory that don't have an extension.
d) Find all files of block size smaller than 1 or larger than 3.
e) Find all files of block size larger 2 and list them in a long listing.
f) Find all files that were modified today.
g) Find all directories on the system that are owned by you.
h) Find all files on which everybody has write permit.
cat |
more |
| head |
head [-count] [file1 file2 ...]
| tail |
| |
Exercises
Display the last 15 lines of a file. Display the first 5 lines of a file first using head, then using tail. Display the first 5 lines with line numbers.
sort |
uniq |
| crypt |
| cmp |
| diff |
| split |
| tr |
| |
Exercise
Replace all blanks in a textfile by newline characters (newline characters can be represented as '\012'). Sort the output and then display it counting the duplicates. Sort it again so that the most frequent words are displayed first. Display only the first ten lines of that result.
newline (enter) | |
; | |
& |
|
Exercise
Execute the following: a) date RETURN who RETURN
b) date; who
c) date & who
ps |
top | shows top processes in the system
| jobs | shows background jobs
| bg |
| fg |
| kill |
| sleep |
example: (sleep 5; echo "Hello")&
| at |
| nice |
| wait |
| nohup |
| |
Exercise
a) Try the different ps options. Type "more &" then "pico &" then "ps -l". Which of the processes is the parent? What is the id of the parent process? In what states are the processes?
b) Type "jobs". Then bring the "more" process into the foreground. Find the process id of the "pico" process and kill it.
c) Type "emacs". Then put the process into the background using a second terminal window. Then kill the emacs process.
d) Find out what the current time is. Using "at" echo "hello" to a new file to be executed exactly 2 minutes later.
xterm |
xhost |
| xclock |
| xcalendar |
| xkill |
| xman |
| |
Exercise
Open xterm window with black background and white foreground that runs in the background.