CSE 391: System & Software Tools
Shell
What is 391?
Learning objectives: collection of tools and topics not addressed in other classes that we think all CSE majors should know.
Bottom line: this class exists for your benefit!
What is 391?
Logistically,
Getting Help: Office Hours & Ed
Synchronous help: come to office hours!
Asynchronous help: post on the Ed Discussion board!
Getting Help: Everything Else
Discuss something that requires privacy? Feel free to sign up for a meeting.
In particular:
Bottom line: please reach out!
You get what you put in
I am not expecting this class to be your #1 priority in life! But in order to learn the material you will need to:
This class should not be a major source of stress/work but, there’s a ton of room to explore if you’re interested
Operating Systems?
In the study of operating systems, a kernel is the program that manages software & hardware resources such as memory, networking, user input, etc.
Kevin’s laptop runs ChromeOS and his phone runs Android: both of these operating systems are based on the Linux kernel.
macOS and iOS are Unix-like but not based on the Linux kernel.
Windows is not Unix-like.
Operating Systems?
What are the most common operating systems for…
Shell?
Despite differences, we often use computers via a desktop environment that helps you run apps and edit files using a mouse, keyboard, or touchscreen.
You’ve learned Java programming, which lets you compute new things. But it’s often uncomfortable writing Java programs that interact with files or run apps.
e.g. printing out the contents of a file can take 20 lines of Java code
The shell is a more direct way to write programs that interact with files.
e.g. the same task can be done in 1 line with the cat shell command
Why Unix & Linux? (1/2)
Introduced many key ideas:
Why Unix & Linux? (2/2)
Widely impactful & influential:
Bottom line: almost impossible to “dodge” Linux as a programmer!
the rest of this is a live demo :)
Appendix: Commands
Anatomy of a Command
Command line arguments surprisingly can be inconsistent, but for this class we’ll split them up into the command, optional flags, and optional arguments.
$ ls -al dir1
Command
Flags
Arguments
(Parameters)
Command Line Arguments
Much like methods in Java (or other languages), commands take “arguments”.
For example, the following line lists all the files inside of the dir1 folder:
$ ls dir1
Here, we’ll say that dir1 is an argument to ls. Arguments are separated by spaces.
Flags are a special type of argument that typically change the behaviour of a program slightly; they are usually prepended with a - or –. For example,
$ ls -al dir1
Combines two flags: the -a flag (list hidden files) and the -l flag (use long-list format).
Basic Shell Commands
command | description |
pwd | Print current working directory |
cd | Change working directory |
ls | List files in working directory |
man | Bring up manual for a command |
exit | Log out of shell |
System Commands
command | description |
clear | Clears all output from console |
date | Output the system date |
cal | Output a text calendar |
uname | Print information about the current system |
Relative Directories
directory | description |
. | References the working directory |
.. | References the parent of working directory |
~username | username’s home directory |
~/Desktop | Your desktop |
Unix File System Conventions
directory | description |
/ | Root directory that contains all directories |
/bin | Applications/programs (i.e. binaries) |
/dev | Hardware devices |
/etc | Configuration files |
/home | Contains user’s home directories |
/proc | Running programs (processes) |
/tmp, /var | Temporary files |
/usr | Universal system resources |
Directory Commands
directory | description |
ls | List files in working directory |
pwd | Print current working directory |
cd | Change working directory |
mkdir | Make a new directory |
rmdir | Remove the given directory (must be empty) |
File Commands
directory | description |
cp | Copy a file |
mv | Move a file (also used to rename files) |
rm | Remove the given file |
touch | Create empty file, or change time-modified |
Warning: the above commands do not ask for confirmation. �Be careful when moving, copying, or deleting files!�(the man pages have flags that prevent this behaviour!)
Text Editors
command | description |
nano | Very simple editor |
vim | More advanced text-editor |
emacs | More advanced text-editor |
In many instances, you’ll be interacting with a Linux system only through a console – so a command-line text editor is necessary.
vim is the main text editor we will learn in this class.
vim basics
Key stroke | description |
:w | Write (save) the current file |
:wq | Write (save) the current file and exit |
:q! | Quit, ignoring all changes |
i | Go into insert mode |
Esc | Go back to normal mode |
hjkl | Move cursor left, down, up, right |
u | Undo last change |
x | Delete character |
emacs basics
Key stroke | description |
C-x C-f | Read a file into emacs |
C-x C-s | Save a file to disk |
C-x C-c | Exit emacs |
C-s | Search forward |
C-r | Search backwards |
C-v | Scroll to next screen |
M-v | Scroll to previous screen |
C-x u | Undo |
C = control key
M = alt/meta key