Session 1. Basic UNIX commands
Syntax:
command option(s) filename(s)
1. Simple commands: % date [today's date] % cal [calendar] % whoami [user's identity] % who [logged users] % hostname [computer's identity] % man command [help about command]
2. Browsing the file system: % pwd [print work directory] % ls [list] % cd dir [change directory] % cd [back to home directory] % ls -alh [list all/long/human-readable] % ls *.doc [matches any string] % ls chapter? [matches any single character] % ls chapter[1-3] [range]
3. File system management: % cp old new [copy] % mv old new [rename, move] % rm file [remove] % mkdir dir [dir creation] % rmdir dir [dir remove] % cp -r dir1 dir2 [directory copy] % rm -i file [interactive] % rm -rf dir [remove all: attention!!]
4. Protection and permissions: % chmod bits element [change permissions] % chmod 644 file [set RW-R--R--] % chmod g+w file [set W for group] % chmod 744 dir [access directory permissions]
5. File edition: % emacs file [emacs reference card]
Practice 1. Basic UNIX commands
Type the following commands (tutorial):
- % cd
- % pwd
- % mkdir work1
- % cd work1
- % mkdir docs
- % mkdir images
- Save this picture in the images directory
- % cd docs
- % emacs Quijote.txt
- Write the following text:
"En un lugar de la Mancha, de cuyo nombre no quiero acordarme, no ha mucho que vivía un hidalgo de los de lanza en astillero, adarga antigua, rocín flaco y galgo corredor"
- Search the word "hidalgo"
- Replace the word "hidalgo" for "caballero andante"
- Save the file [C x+s]
- Insert a new line at the beginning of the file
- Save the file and exit [C x+c]
- % pwd
- % ls
- % ls ..
- % ls ../..
- % ls -lh Quijote.txt
- % chmod 600 Quijote.txt; ls -lh Quijote.txt
- % chmod g+r Quijote.txt; ls -lh Quijote.txt
- % cd ..
- % ls docs/Q*
- % ls images/*.jpg
- % mv images pictures
- % ls
- % cd ..
- % cp -r work1 work1_backup
- % rmdir work1_backup
- % ls
- % man rmdir
- % rm -rf work1_backup
- % ls
- % history
Enrique Blanco © 2004 -- eblanco@imim.es