CS6 PracticalSystemSkillsFall 9 editionLeonhard Spiegel erglspiegel@ s. rown.edu
. Re ap
2 / 68
. Re ap
/
⇒ /
⇒ . .. ~
cd
ls
3 / 68
. Re ap uiz
/usr/local/bin
cd ..
cd ./../..
cd
cd ~
4 / 68
. Re ap uiz
/usr/local/bin
cd .. /usr/local
cd ./../.. /usr
cd HOME directory
cd ~ HOME directory
5 / 68
. Re ap uiz
ls Documents
ls
ls -a
6 / 68
Documents
mail .backups
2018 2019 .backupdb
cwd
. Re ap uiz
7 / 68
Documents
mail .backups
2018 2019 .backupdb
cwdls Documents
ls: Documents: No such file or directory
ls
ls -a
. .. mail .backups
FilesCS6 Pra ti al System SkillsFall 9Leonhard Spiegel erg lspiegel@ s. rown.edu
. C eatin and deletin files
9 / 68
touch file mkdir directory_name
rm file rmdir directory_name
. Wo kin ith di e to ies
-p
mkdir -p folder/subfolder/subsubfolder
10 / 68
. Deletin files and di e to ies
11 / 68
. Deletin files
-r
rm -r folder/
12 / 68
. Deletin files in a t ee
-r
-i
Example:
rm -ri folder/
13 / 68
. Deletin files in a t ee
-r
-f
Example:
rm -rf folder/
14 / 68
Ba k to the te minal...
. O anizin files
16 / 68
mv src ... destmove file from src location to dest location⇒ can be used to rename a file
cp src ... destcopy file from src location to dest location
. Cop in di e to ies
cp -R src dest
/ cp
17 / 68
. Cop in di e to ies
Examples: cp -R folder copy
18 / 68
cwd cwd
. Cop in di e to ies
Examples: cp -R folder/ copy
19 / 68
cwd cwd
. Cop in di e to ies
Examples: cp -R folder/ .
20 / 68
cwd cwd
. Cop in di e to ies
Examples: cp -R folder/ dest
21 / 68
cwd cwd
. Cop in di e to ies
Examples: cp -R folder dest
22 / 68
cwd cwd
. Mo in di e to ies
mv folder dest
mv folder/ dest
23 / 68
cwd cwd
. Renamin files/di e to ies
⇒ dest mv
⇒ -n -i
24 / 68
cwd
mv folder/a.txt folder/file.txt
cwd
. Renamin files/di e to ies
⇒
25 / 68
cwd
mv folder dir
cwd
Ho to m o p a su set o files?
. UNIX ild a ds
⇒
27 / 68
. UNIX ild a ds
28 / 68
*
?
[...]
[a-z]
[0-9]
[a-zA-Z]
[a-zA-Z0-9]
[!...]
[!123]
Hint: escape [, *, ? using a backslash, e.g. * ⇒ \*
. UNIX ild a ds - e ample
⇒
29 / 68
/*folder/file?.txt
/folder/file1.txt/subfolder/filea.txt/subsubfolder/fileB.txt
folder/file.txtfolder/file1.txt/subfolder/a.txt/folder/subfolder/file1.txt
. UNIX ild a ds
mv *.jpg images/
mv *?.jpg images/
30 / 68
. UNIX ild a ds
mv *.jpg images/
mv *?.jpg images/
31 / 68
. UNIX ild a ds
cp [0-9][0-9]_*.pdf slides/
32 / 68
. UNIX ild a ds
⇒
⇒
33 / 68
mv {*.png,*.jpg} images/
. B a e e pansion
{...}
{*.png,*.jpg}⇒ *.png *.jpg
Example:
mv {*.png,*.jpg} images/
⇒ mv *.png *.jpg images/
34 / 68
. B a e e pansion
Shorter version:
mv *.{png,jpg} images/
⇒ mv *.png *.jpg images/
35 / 68
. B a e e pansion
Example:
ls {lecture,slide*}_??.{pdf,dvi}
⇒ ls lecture_??.pdf lecture_??.dvi slide*_??.pdf slide*_??.dvi
36 / 68
. B a e e pansion
⇒
Examples:
ls {a,b{c,d}}.txt
⇒ ls a.txt b{c,d}.txt
⇒ ls a.txt bc.txt bd.txt
ls {a,{b,c}}.txt
⇒ ls a.txt b.txt c.txt37 / 68
. B a e e pansion
cp file{,.backup}
⇒ cp file file.backup
38 / 68
. UNIX ild a ds
cp *.*{,.backup}
⇒ cp *.* *.*.backup
⇒
⇒
39 / 68
Ho an e a ess the ontents o a file?
. File t pes
⇒
⇒
41 / 68
. Te t files
cat file …
42 / 68
. Te t files - ISO/IEC -
⇒
⇒
44 / 68
. Te t files - ASCII and UTF- en odin
⇒
45 / 68
. Te t files - UTF- en odin
46 / 68
number of bytes Byte 1 Byte 2 Byte 3 Byte 4
1 ASCII chars 0xxxxxxx
2Latin, Greek, Cyrillic, Coptic, Armenian, Hebrew, Arabic,
Syriac, Thaana, ...110xxxxx 10xxxxxx
3 Chinese, Japanese, Korean, …. 1110xxxx 10xxxxxx 10xxxxxx
4 Math symbols, Emojis 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
. Editin te t files
47 / 68
⇒
. Bina files
⇒
hexdump file
⇒
48 / 68
. he dump
49 / 68
hexdump penguin.jpg
0000000 ff d8 ff e1 12 d4 45 78 69 66 00 00 4d 4d 00 2a0000010 00 00 00 08 00 0c 01 00 00 03 00 00 00 01 08 000000020 00 00 01 01 00 03 00 00 00 01 0c 00 00 00 01 020000030 00 03 00 00 00 03 00 00 00 9e 01 06 00 03 00 000000040 00 01 00 02 00 00 01 12 00 03 00 00 00 01 00 010000050 00 00 01 15 00 03 00 00 00 01 00 03 00 00 01 1a0000060 00 05 00 00 00 01 00 00 00 a4 01 1b 00 05 00 000000070 00 01 00 00 00 ac 01 28 00 03 00 00 00 01 00 020000080 00 00 01 31 00 02 00 00 00 24 00 00 00 b4 01 320000090 00 02 00 00 00 14 00 00 00 d8 87 69 00 04 00 00...
. he dump s. at
50 / 68
cat file.txt
Tux loves CS6
hexdump -c file.txt
0000000 T u x l o v e s C S 6 \n000000e
hexdump file.txt
0000000 54 75 78 20 6c 6f 76 65 73 20 43 53 36 0a000000e
⇒
. file
file file
⇒
⇒
51 / 68
Example:
file penguin.jpg
penguin.jpg: JPEG image data, Exif standard: [TIFF image data, big-endian, direntries=12, height=3072, bps=0, PhotometricIntepretation=RGB, orientation=upper-left, width=2048], progressive, precision 8, 512x513, frames 3
. Uni o a ula so a
52 / 68
cd
ls
touch
rm
mkdir
rmdir
mv
cp
cat
hexdump
file
Use s and Pe missions
CS6 Pra ti al System SkillsFall 9Leonhard Spiegel erg lspiegel@ s. rown.edu
. Pe missions
54 / 68
. Pe missions
55 / 68
. Pe missions o di e to ies
56 / 68
. Use s and pe missions
⇒
⇒
57 / 68
. Use s and pe missions
58 / 68
⇒
. ls lon o mat
ls -l
total 88
-rw-r--r-- 1 sealion friends 14 9 Sep 8:01 file.txt
-rw-r--r-- 1 sealion friends 40390 9 Sep 9:00 penguin.jpg
59 / 68
owner and user are usually the same! Terms are used interchangeably here often.
. Pe missions
60 / 68
- rw- r-- --x
-
d
l
p
s
b
c
. Settin pe missions - hmod
chmod mode file …
⇒
⇒
61 / 68
. hmod - s m oli mode
chmod u=rw,g=rx,o= file.txt
62 / 68
. hmod - nume i mode
63 / 68
0 000 ---
1 001 --x
2 010 -w-
3 011 -wx
4 100 r--
5 101 r-x
6 110 rw-
7 111 rwx
chmod u=rw,g=rx,o= file.txt ⇒ chmod 650 file.txt
Mo e details ne t le tu e!
P e ie ne t le tu e
⇒
⇒
⇒
⇒
65 / 68
P e ie HW :
66 / 68
P e ie La :
⇒
67 / 68
End of lecture.Next class: Thu, pm- :20pm @ CIT 77