Unix-Like-Systems
Unix-Like-Systems
Computing Laboratory
http://www.isical.ac.in/~dfslab
1 Getting started
3 Commands
File manager
1 Getting started
3 Commands
Courtesy: https://www.slideshare.net/okmomwalking/windows-7-unit-b-ppt
Folders ≡ directories
Top of the hierarchy: root directory (/)
Default starting location: home directory (~)
Location of a file or directory: specified by path
Current location in terminal or file browser: current working directory
Paths: absolute or relative
absolute path: from root (starts with /)
Example: /usr/bin/firefox, /tmp, /user1/student
relative path: from current working directory (does not start with /)
Example: clab/assignment1/hello.c
Example:
$ /bin/ls -l
total 68
drwx------ 2 mandar mandar 4096 Jul 19 00:45 assignments
drwx------ 2 mandar mandar 4096 Jul 22 2016 exams
-rw-r--r-- 1 mandar mandar 13521 Jul 19 00:41 index.html
drwx------ 2 mandar mandar 4096 Jul 19 00:45 lectures
Computing Lab (ISI) Introduction to UNIX-like systems 11 / 20
Essential commands: permissions
Permissions:
9 possible permissions:
{ read, write, execute } × { user (owner), group, other (everyone else) }
9 bits (1 ≡ permission granted)
ur uw ux gr gw gx or ow ox
chmod: changing permissions
Example:
chmod g+wx <path>
chmod og-wx <path>
chmod 644 <path> ←− 644 ≡ 110 100 100 ≡ rw-r--r--
chmod 700 <path> ←− 700 ≡ 111 000 000 ≡ rwx------
1 Getting started
3 Commands
Compiling
command options / flags other arguments
gcc -g -Wall -o prog1 prog1.c
OR
cp : copy a file
Example:
cp program1.c program2.c
cp -i source-file target-file
cp -i source-file target-directory
cp : copy a file
Example:
cp program1.c program2.c
cp -i source-file target-file
cp -i source-file target-directory
mv : rename (move) a file
Example:
mv program1.c program2.c
mv -i source-file target-file
mv -i source-file target-directory
cp : copy a file
Example:
cp program1.c program2.c
cp -i source-file target-file
cp -i source-file target-directory
mv : rename (move) a file
Example: -i ≡ interactive
mv program1.c program2.c (asks for confirmation)
mv -i source-file target-file
mv -i source-file target-directory
rm : remove (delete) a file
Example:
rm program1.c
rm -i file1 file2.c *.bak
rm -r some-directory (remove directory and everything inside it)
Input/output
involves a file or a terminal
requires a file pointer
stdin ≡ file pointer corresponding to reading input from keyboard
stdout ≡ file pointer corresponding to printing output to terminal
Taking stdin from a file: ./prog1 < input.txt
Printing stdout to a file: ./prog1 > input.txt
Taking stdin / printing stdout from / to a program: use the vertical bar /
pipe character (|)
./prog1 | less
cat input.txt | ./prog1
Input/output from/to file / program may be combined
./prog1 < input.txt > output.txt
man
Example: man ls, man cp, man rm
man
Example: man ls, man cp, man rm
http://cli.learncodethehardway.org/bash_cheat_sheet.pdf
https://ubuntudanmark.dk/filer/fwunixref.pdf
http://www.ucs.cam.ac.uk/docs/leaflets/u5
http://mally.stanford.edu/~sr/compuGng/basic-unix.html
http://www.math.utah.edu/lab/unix/unix-commands.html