Introduction To Linux Unix Environment
Introduction To Linux Unix Environment
• brief history:
Multics (1964) for mainframes
Unix (1969)
Lecture 1
K&R
Linus Torvalds and Linux (1992)
• key Unix ideas:
written in a high-level language (C)
Introduction to Linux/Unix virtual memory
hierarchical file system; "everything" is a file
environment lots of small programs that work together to solve (giải quyết) larger
problems
security, users, access, and groups
human-readable documentation included
1 2
1 2
3 4
3 4
1
Things you can do in Linux Shell
• Load the course web site in a browser • shell: An interactive program that uses user input to manage the
execution of other programs.
• Install and play games A command processor, typically runs in a text window.
User types commands, the shell runs the commands
• Play MP3s Several different shell programs exist:
• bash : the default shell program on most Linux/Unix systems
• We will use bash
• Edit photos • Other shells: Bourne, csh, tsch
• IM, Skype • Why should I learn to use a shell when GUIs exist?
5 6
5 6
7 8
7 8
2
Relative directories Directory commands
directory description
command description
. the directory you are in ("working directory")
ls list files in a directory
.. the parent of the working directory
pwd print the current working directory
(../.. is grandparent, etc.)
~ your home directory cd changes the working directory
(on many systems, this is /home/username ) mkdir create a new directory
~username username's home directory rmdir delete a directory (must be empty)
~/Desktop your desktop
9 10
9 10
• input: comes from user's keyboard • many programs accept a --help or -help option to give more
• output: goes to console information about that command (in addition to man pages)
• errors can also be printed (by default, sent to console like output) or if you run the program with no arguments, it may print help info
• parameters vs. input • for many commands that accept a file name argument, if you omit
parameters: before Enter is pressed; sent in by shell (bỏ sót/quên) the parameter, it will read from standard input (your
input: after Enter is pressed; sent in by user keyboard)
11 12
11 12
3
Shell/system commands File commands
command description command description
man or info get help on a command cp copy a file
clear clears out the output from the console mv move or rename a file
exit exits and logs out of the shell rm delete a file
touch create a new empty file, or
command description update its last-modified time stamp
date output the system date
• caution: the above commands do not prompt for confirmation
cal output a text calendar
easy to overwrite/delete a file; this setting can be overridden (how?)
uname print information about the current system
• Exercise : Given several albums of .mp3 files all in one folder, move
• "man pages" are a very important way to learn new commands
them into separate folders by artist.
man ls
man man • Exercise : Modify a .java file to make it seem as though you
finished writing it on Dec 28 at 4:56am.
13 14
13 14
• Exercise : Modify a .java file to make it seem as though you line C-p C-n
finished writing it on Dec 28 at 4:56am. go to line beginning/end C-a C-e
touch –t "201812280456" Hello.java go to buffer beginning/end M-< M->
15 16
15 16
4
Basic Vim Commands
• :w Write the current file
• :wq Write the current file and exit.
• :q! Quit without writing
• To change into insert mode: i or a
Use escape to exit
• search forward /, repeat the search backwards: N
• Basic movement:
hlkj character left, right; line up, down (also arrow keys)
bw word/token left, right
ge e end of word/token left, right
0$ jump to first/last character on the line
• x delete
• u undo
17
17