260 likes | 448 Views
CO004 Projects on Operating Systems. UNIX - Basics. Outline. Introduction to UNIX UNIX file systems How to connect to UNIX UNIX Access Control on files UNIX Commands - Handling Files and Directories. What is Unix?.
E N D
CO004 Projects on Operating Systems UNIX - Basics
Outline • Introduction to UNIX • UNIX file systems • How to connect to UNIX • UNIX Access Control on files • UNIX Commands - Handling Files and Directories
What is Unix? • Unix is just an operating system. It provides the same functionality as the operating systems we all know. • What makes Unix slightly more challenging, is it’s lack of the clickable graphical user interface we are all so accustomed to. • Don’t worry, it’s really not as difficult as it may seem at first! You’ll be a Unix expert in no time.
Structure of UNIX • Hardware • Kernel • Utilities • Shell Hardware Kernel Utilities Shell
File System Structure • To start out, you need to have an understanding of how Unix arranges it’s files. So let’s call the file system a tree. • Think about hanging the tree upside down. All branches (directories) come from the trunk (root), or from other branches (directories). • So if the branches are file folders (directories), then the leaves must be the files contained in the directories!
File System Structure • The trunk is the root directory. • Branches are directories. • Leaves are files.
Example of UNIX file system • Filenames case sensitive • Physical devices can be mounted anywhere / tmp dev etc home usr chris mary lib include bin local lib include bin hello.c test.cpp
File System Structure • So does the file system structure of Unix look similar to another operating system? • It should! It’s very similar to any windows, mac, or linux operating system! • A path to a file from the root could look something like this: /home/chris/hello.c • So you should already know how things work. You just need to know the Unix commands to get around! Note that Unix uses the forward slash! (Opposite of windows)
Connection to LINUX server • Use SSH client: • Any clients supporting SSH connection • Putty • SSH Client • How to access • Server’s ip: 10.4.40.198 • Account (see next slide)
Your account • Your account: • Your student ID: 1009853X-I011-YYYY • s10XYYY • If X denotes a digit, then keep it. • If X denotes an upper-case letter, then keep itunchanged. • YYY shall be the last three digits. • Password • 123456
Login the system • Display like this: • s10XYYY@:~$ • You can change your password later:
UNIX Commands • [s10XYYY@~] $ command [-options] parameter1 parameter2 • command: name of executed programs • options: optional • parameters: optional • Note: most of commands are case sensitive
Basic Unix Commands • Clear – clears the screen • “clear” will give you a blank screen. You can still scroll up to see your text again in putty. • Cat – displays a file (all at once) • “cat myfile” will print out myfile to the screen. • Man – Displays a manual for any command • “man pwd” will give you the manual for the pwd command. • Exit – exits Unix • “exit” will log you out and close putty.
Identifying UNIX Users • The who command identifies current users who are logged on: host% who rbarrett ttyp0 Apr 03 13:46 (spam.lanl.gov) ahg ttyp1 Apr 02 08:27 (penning.lanl.gov) jbp ttyp2 Apr 02 08:58 (telemachus.lanl.) jimm ttyp3 Apr 02 08:52 (ts800-1-tig.lanl) operator ttyp6 Apr 02 09:20 (ibm-op) cadams ttyp7 Apr 15 10:28 (maccda2.mst.lanl)
Handling Files and Directories • ls: list files • cp: copy files • mv : move files • rm : remove files • mkdir: make directories • cd : change directories • rmdir: remove directories • pwd: print working directory • chmod : change permission mode
ls command • Syntax • ls [-Options] [name ...] • Description • Lists contents of directory. • Frequently Used Options • -a List all entries, including . and .. • -d Do not list contents of directories • -lLong listing • -F Mark directories with a '/', etc. • Examples • ls -alF
UNIX access control • File access – regulated by three sets of permissions • Permissions: read (R), write (W), execute (X) • Subjects: owner, group, all
cp command • Syntax • cp [-Options] file1 [file2 ...] target • Description • File1is copied to target. • Frequently Used Options • -f Force remove existing file • -i Ask before removing existing file • -r Copy directory trees • Examples • cp p1.c p2.c • cp p1.c p2.c mydir
mv command • Syntax • mv [-Options] file1 [file2 ...] target • Description • File1 is moved to target. • Frequently Used Options • -fRemoves existing files without prompting the user • -i Asks before removing existing file • Examples • mv p*.c mydir
rm command • Syntax • rm [-f] [-i] file . . . • rm -r [-f] [-i] dirname . . . [file . . .] • Description • Removes files or directories. • Frequently Used Options • -f Removal of files without prompting the user • -i Interactive removal • -r Recursive removal • Examples • rm -f p*.o • rm -r mydir
mkdir command • Syntax • mkdir [-m mode] [-p] dirname . . . • Description • Creates the specified directories. • Options • -m Specifies the mode to be used • -p Create missing intermediate directories • Examples • mkdir -m 700 letter • mkdir abc • mkdir -p ./abc/def/ghi
cd command • Syntax • cd [directory] • Description • Change working directory. • If directory is not specified, the value of shell parameter $HOME is used as the new working directory. • Examples • cd • cd ./abc/def/ghi • cd ..
rmdir command • Syntax • rmdir [-p] [-s] dirname . . . • Description • Removes directories. • Options • -p Remove the directory dirname and its parent directories which become empty. • -s Suppress the message when –p is in effect • Examples • rmdir letter
pwd command • Syntax • pwd • Description • Prints the path name of the working (current) directory. • Examples • pwd
chmod command • Syntax • chmod [-R] mode file ... • chmod [-R] [ugoa]{+|-|=}[rwxXstl] file ... • Description • Changes the permissions mode of a file or directory. • Examples • chmod 444 file1 • chmod ugo+rw p*.c • chmod 700 mydir
Change password • You can change your password by this command: • s10XYYY@ubuntu:~$ passwd Changing password for s10XYYY. (current) UNIX password: … • Principles of your password: • Not the same as your account • Longer password, at least 8 characters • Not your personal information • Not dictionary words • Good with combination of letters, digital numbers and special characters ($,@, & etc.)