CS Help Desk: Marc Jarvis (in spirit), Monica Ung, Corey Antoniuk 2015
Unix Tutorial
Beginner
CS Help Desk: Marc Jarvis (in spirit), Monica Ung, Corey Antoniuk 2015
Helpful info
SOCS wiki
cs.mcgill.ca/docs
Help desk - McConnell 209N
CSUS help desk - 3rd floor Trottier (look for the flag)
http://csus.cs.mcgill.ca/
CS Help Desk: Marc Jarvis (in spirit), Monica Ung, Corey Antoniuk 2015
Account creation / logging in
Create your CS account:
https://newuser.cs.mcgill.ca/
Reset password (generates new password):
https://newpassword.cs.mcgill.ca/
McGill Username: [email protected]
McGill Password: same password to log into your mcgill e-mail
Change password through terminal:
● passwd
To change password with passwd, you have to be SSH’ed into one of the SOCS servers
(eg: mimi.cs.mcgill.ca, teaching.cs.mcgill.ca)
CS Help Desk: Marc Jarvis (in spirit), Monica Ung, Corey Antoniuk 2015
GUI - Graphical User Interface
CS Help Desk: Marc Jarvis (in spirit), Monica Ung, Corey Antoniuk 2015
Common Applications
Software probably needs admin permissions to install
Browser: Firefox
Word processing: LibreOffice Writer
Text editing: Emacs, Sublime, Text Editor, Geany
IDE: Eclipse
Graphics: Gimp, Blender, Wings 3D
Computation: Matlab, LibreOffice Calc
CS Help Desk: Marc Jarvis (in spirit), Monica Ung, Corey Antoniuk 2015
CS Account
CS Mail Account: https://mail.cs.mcgill.ca/ (by request)
can have a vanity name
Printing:
McGill uPrint: http://kb.mcgill.ca/it/uprint
6 cents per page
Charged on your McGill student account (check in
Minerva)
Network with daily backup
Personal website: cs.mcgill.ca/~username
CS Help Desk: Marc Jarvis (in spirit), Monica Ung, Corey Antoniuk 2015
Terminal
Command Line Editor
Text-based access to the operating
system
Why is it useful?
Almost everything is configurable through
command line
Powerful, flexible, efficient
combine commands
can do things that you can’t do
through GUI
Standardized - same “syntax” for all POSIX
compliant machines
Used in many CS courses
CS Help Desk: Marc Jarvis (in spirit), Monica Ung, Corey Antoniuk 2015
Anatomy of a command
commandName [-option] [argument]
Examples:
● date
● cal
● whoami
● ls -l
List all files and directories in the current directory. “-l” = long. Descriptive list.
CS Help Desk: Marc Jarvis (in spirit), Monica Ung, Corey Antoniuk 2015
Basic terminal commands
ls - List directory
Options:
l = long
a = hidden files
Examples:
● ls -a
● ls -la
CS Help Desk: Marc Jarvis (in spirit), Monica Ung, Corey Antoniuk 2015
Basic terminal commands
cd - Change directory
Examples:
● cd myFolderName
Enter the directory called myFolderName
● cd ..
Move up one directory
● cd -
Return to previous folder
CS Help Desk: Marc Jarvis (in spirit), Monica Ung, Corey Antoniuk 2015
Basic terminal commands
mkdir - Make directory
mkdir newFolderName
cp - Copy file or folder
cp myFile someFolder/copiedFile
mv - Move file or folder
mv myFile someFolder/copiedFile
CS Help Desk: Marc Jarvis (in spirit), Monica Ung, Corey Antoniuk 2015
Getting more info
man - Manual
Example:
● man mv
--help
Example:
● mv --help
NAME
mv - move (rename) files
SYNOPSIS
mv [OPTION]... [-T] SOURCE DEST
mv [OPTION]... SOURCE... DIRECTORY
mv [OPTION]... -t DIRECTORY SOURCE...
DESCRIPTION
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.
Mandatory arguments to long options are mandatory for short options
too.
--backup[=CONTROL]
make a backup of each existing destination file
-b like --backup but does not accept an argument
-f, --force ...
CS Help Desk: Marc Jarvis (in spirit), Monica Ung, Corey Antoniuk 2015
Creating a file
touch - Creates a file
Example:
● touch myFileName
cat - Catenate
Example:
● cat > filename
● ^Z to quit
CS Help Desk: Marc Jarvis (in spirit), Monica Ung, Corey Antoniuk 2015
Viewing a file
cat - Catenate
tac - Catenate in reverse
Examples:
cat file1 file2
tac file1
less - show content one page at a time
by window: b=backwards and f=forwards
by line: k=backwards and j=forwards
cat | less or cat | head or cat | tail
CS Help Desk: Marc Jarvis (in spirit), Monica Ung, Corey Antoniuk 2015
Editing a file
vim - Vi IMproved
‘a’ or ‘i’ to enter Insert Mode
‘esc’ to enter Command Mode
:q :wq :q! → exit
nano - Nano’s ANOther editor
Helpful interface
CS Help Desk: Marc Jarvis (in spirit), Monica Ung, Corey Antoniuk 2015
File Information
touch file.txt
ls -l file.txt
> -rw------- 1 jsmith nogroup 0 Sep 23 10:14 file.txt
[permissions][# of links][user][group][filesize][date modified][filename]
● Permissions: drwxrwxrwx
[directory?][user][group][others]
CS Help Desk: Marc Jarvis (in spirit), Monica Ung, Corey Antoniuk 2015
File Permissions - Method 1
chmod - Change file mode bits
r:read, w:write, x:execute
u:user, g:group, o:others, a:all three (ugo)
Examples:
● chmod a+rx file
Add read and execute permissions to all
● chmod ou-rw
Remove read and write permissions from others and the user
CS Help Desk: Marc Jarvis (in spirit), Monica Ung, Corey Antoniuk 2015
File Permissions - Method 2
chmod - Change file mode bits
Examples:
● chmod 777 file
Enable full permissions to all three
● chmod 652 file
Enable read and write to user,
read and execute to group,
write to others
rwx____
000 = 0
001 = 1
010 = 2
011 = 3
100 = 4
101 = 5
110 = 6
111 = 7
-rw-r-x-w- = 652
CS Help Desk: Marc Jarvis (in spirit), Monica Ung, Corey Antoniuk 2015
Deleting a file or directory
rm - Remove
Example:
● rm file
● rm -r directory
● rm -f file (remove prompt)
rm -rf directory (delete folder)
CAUTION: rm -rf *.*
CS Help Desk: Marc Jarvis (in spirit), Monica Ung, Corey Antoniuk 2015
Storage Space
du - File Usage
● du file (kilobytes)
du -b file (bytes)
df -h - File System Disk Space
free - Display Free and Used Memory
CS Help Desk: Marc Jarvis (in spirit), Monica Ung, Corey Antoniuk 2015
References
Terminal Command Index
http://community.linuxmint.com/tutorial/view/244
Vim text editor tutorial
http://www.openvim.com/tutorial.html
CS Help Desk: Marc Jarvis (in spirit), Monica Ung, Corey Antoniuk 2015
Connecting from home with SSH
Unix (use terminal)
eg: ssh [email protected]
fingerprint prompt for first time
user (yes)
password
‘exit’ or Ctrl D to quit
Windows (use Putty)
Host: teaching.cs.mcgill.ca