1 CPS393 LinuxBashIntro-1
1 CPS393 LinuxBashIntro-1
1 CPS393 LinuxBashIntro-1
Alex Ufkes
aufkes@ryerson.ca
Class times (Sec 5-7):
Tue 11-1, TRS 1149
Fri 12-1, DSQ 14
Class times (Sec 8-11):
Mon 11-12, TRS 3176
Wed 8-10, TRS 3176
https://www.cs.ryerson.ca/dwoit/courses/cps393/cmf393.html
https://www.cs.ryerson.ca/dwoit/courses/cps393/courseNotesREADME
The course introduces the UNIX operating system, and the C and C++
languages. UNIX topics include: I/O, redirection, processes, and shell
scripts. C and C++ are introduced with an emphasis on differences from
previously studied languages. C topics include pointers, structures,
memory allocation, and paradigm differences. C++ topics include class
formalisms, static and dynamic instantiation, inheritance, constructors
and destructors, polymorphism with virtual functions, operator
overloading, and time permitting, friends. Stream I/O may be introduced.
Labs are not graded. Provided questions are for practice only.
TAs will be available to answer questions and check your work.
All lab related inquiries should be sent to your lab TA
Our lead TA is Jorge Lopez: jlopez@ryerson.ca
Broadly Speaking:
The OS communicates with the hardware resources of the
computer system to provide a set of services to system users.
The Kernel is the heart of the OS that operates closest to the hardware layer.
https://interworks.com/blog/2021/09/08/how-to-enable-ssh-commands-in-windows/
Important!
To log into moon, type:
ssh moon.cs.ryerson.ca
Use SSH similarly from this terminal, but this time include CS userID:
ssh aufkes@moon.cs.ryerson.ca
happen (hopefully)
Rules:
File names are case sensitive MyFile and myfile are different.
Max length of 255 characters, though this can vary by platform.
Suffix or file extension not required myfile and myfile.txt are both OK
Organized like a tree, where the top of the tree is called root (or root directory)
Working directory:
in
Root directory
/home/aufkes
/home/dwoit
Etc.
home/chara adool:I
Home directory
abbreviated to ~
/usr/courses
Shortcut to
home dir
Navigation with cd
\n at the end)
Remember this?
rm r <dir>
dir
and all files and sub-dirs
© Alex Ufkes, 2022 64
Linux Command Options: ls
These commands
can be looked up in
man as well!
https://linux.die.net/man/
https://www.gnu.org/software/bash/manual/html_node/
Owner Group
Each file and directory has an owner and a group associated with it
What about
this stuff?
Owner and group
© Alex Ufkes, 2022 79
Permissions
What about
this stuff?
I >
directory
u g o Each of:
owner group everyone
else
owner (u) group members (g) other users (o)
I can read/write hello.txt have a set of :
read (r) write (w) execute (x)
permissions.
© Alex Ufkes, 2022 80
For
; ÷ %•
-
mm
'
* Hit
an
Haniya
Neeley *agar and
*
Yana Hagiwara rwx
\
Perms?
Group and other have no permissions at all: ---
-rwxr-xr-- # Original
chmod g+w myFile -rwxrwxr-- # Added write to group
chmod ug-x myFile -rw-rw-r-- # Removed x from u,g
chmod a+r+w+x myFile -rwxrwxrwx # Added r,w,x to all
chmod go=rx myFile -rwxr-xr-x # set g,o to r-x
chmod g=x,o+w myFile -rwx--xrwx # set g to x, added w to o
--- (000) 0
--x (001) 1 Use a 3-digit octal literal to represent
-w- (010) 2 ugo permissions in one shot:
-wx (011) 3
chmod 160 myFile
r-- (100) 4
--x for user, rw- for group, --- for others
r-x (101) 5
rw- (110) 6 Not as intuitive, but potentially much
rwx (111) 7 faster to type
Input
Source Program
Stream
Output
Program Destination
Stream
© Alex Ufkes, 2022 91
CPS209 Reminder
stderr
© Alex Ufkes, 2022 94
IO Streams in Linux
stdin passwd
We tell the commands cat and wc to ignore stdin and use hello.txt instead:
hello.txt cat,wc
Interesting!
lsfile created before ls
command executes!
> will overwrite file if it
exists, create it if not.
>> appends if file exists
Use 2>
Use 2>
Why 2>?
Each stream given a number by shell.
Stdin = 0, stdout = 1, stderr = 2
ls >outfile is same as ls 1>outfile
cat <infile is same as cat 0<infile
Redirect stdout and stderr at
the same time using &>
/dev/stdin
stdin/stdout/stderr are: /dev/stdout
/dev/stderr
Imagine a long list of files for wc, some may not exist.
do exist:
Handy!