260 likes | 364 Vues
Explore the fundamental commands and practices in Linux/Unix environments, understanding file manipulation, directories, moving files, and more. Start your journey to mastering Linux through practical exercises and thorough explanations.
E N D
Introduction to Linux/Unix Working in the CS Environment
What is Linux • OS • Open source • Multiple implementations • Based on Unix
Using Linux • Just like Windows (kinda) • GUI elements • Multiple desktops • Command line
Philosophy of Linux • Many small programs, not one big program • Matches and exceeds functionality of other OS’s • If it’s not there, add it
Creating Files • Kate • touch • vi • gvim • emacs • Lots of possibilities. Pick *one* to start.
The Command Line • Lots and lots of tools that allow you to… • move around • create and remove • edit • pretty well anything else
ls: List files Usage: ls [options] Common options -l (long format) -R (recursive) -t (sort by time) eg: ls -lt cd: Change Directory Usage: cd [pathname] Common options None eg: cd ~/homework/111 Where am I?
mkdir: Make Directory usage: mkdir [directory name] e.g.: mkdir cmpt111 Note: Naming conventions are important to follow Directories
What’s in a Name? • Case sEnsItive • Reserved characters: *.|>< and more • Spaces are a pain • Numbers are allowed, even at the beginning
mv: Move usage: mv [source] [destination] e.g.: mv myfile.txt cmpt111 mv myfile.txt cmpt111/ mv myfile.txt cmpt111/myfile.txt mv myfile.txt cmpt111/myfiletoo.txt Whoops…. we just changed the name. Moving and Renaming
Copying cp: Copy usage: cp [source] [destination] e.g.: cp myfile.txt cmpt111/ cp myfile.txt cmpt111/myfiletoo.txt cp myfile.txt cmpt111 cp myfile.txt cmpt111/myfile.txt
Removing (Deleting) rm: Remove usage: rm [options] [filename] common options: • -r or -R (recursively) • -f (force) • -d (remove directories) e.g.: rm -r cmpt111 rm -rf cmpt111 rm -d * rm myfile.txt
Wildcards and other cool stuff * Any number of any characters ? A single unknown character e.g.: rm m?file.* Also… • Command completion • Command history • Paste buffer -- highlight and middle click(clipboard)
More Cool Stuff ~/ == home ../ == up a level ./ == current level ^C (Control-C) == Emergency Quit exit == quit current shell session
Remote Log-in ssh -- Secure Shell usage: ssh [options] [username]@[hostname] common options: -l [username] login name -D [port] port e.g.: ssh -l amg918 stealth16.usask.ca ssh amg918@stealth16.usask.ca
Where should I ssh? In order…. • stealth37 to stealth50 • stealth20 to stealth36 • stealth1 to stealth19 • penguin Names of machines are “stealth”, “morph”, and “penguin”
How Do I Remember This? • man • apropos
One more useful thing… You have disk space! How much…? • quota [username] • df -h • du -hs
General Comments • Printing: • Get your pages through PAWS • Three printers: • Spinks360bw1 • Spinks315bw1 • Spinks311bw1 • Don’t print to any printers not labelled bw1, it won’t work • Help is available from Seth/Merlin for printing problems
ACM Programming Contest • Every year we field teams • Several practice runs • Faculty coach • Even 1st-years can win! • So can YOU! Today!
The C Programming Language • One of the most basic languages • Very fast, very dangerous • Lots of different compilers • (what is a compiler?) • You will be using a subset of the C++ language
HelloWorld.c Try it! • find HelloWorld.c at /www/docs/bootcamp/2007 • use cp to copy it to your home directory • look at it using kate/vi/emacs • Compile as follows: • gcc -o HelloWorld HelloWorld.c • Run it! (./HelloWorld) What does this do?
Assignment • Navigate to /www/docs/bootcamp/2007 • Copy beginner.txt to your own folder space • Open the assignment in a text editor • Start doing it on your own time