lecture #6: linux basics
Post on 14-Apr-2018
226 Views
Preview:
TRANSCRIPT
-
7/27/2019 Lecture #6: Linux basics
1/25
High performance computing
for non-programmers
Lecture #6:Linux basics
Glib Ivashkevych
junior researcher, NSC KIPT
-
7/27/2019 Lecture #6: Linux basics
2/25
Hardware vs. Software
HW
physical elements of computing system
CPU, memory, system bus, HDD
SW
machine readable instructions that tell HW to performspecific task
OS, system software, application software
-
7/27/2019 Lecture #6: Linux basics
3/25
Operating system
why?
Manages hardware resources
Provides services for application software
Processscheduling
and others
-
7/27/2019 Lecture #6: Linux basics
4/25
Unix
This is the Unix philosophy: Write programs that do one
thing and do it well. Write programs to work together.Write programs to handle text streams, because that is a
universal interface.
Doug McIlroy, developer of Unix pipes
http://en.wikipedia.org/wiki/Standard_streamshttp://en.wikipedia.org/wiki/Computer_program -
7/27/2019 Lecture #6: Linux basics
5/25
Unix
the power of Unix Way
Imagine this:
You have thousands of data files, one per experiment.
Each file contains thousands of measurements.
Some values are wrong, and are denoted as nan.
Files and data lines are numbered conveniently.
Find which measurements in which experiments had
fallen.
-
7/27/2019 Lecture #6: Linux basics
6/25
Unix
the power of Unix Way
Shell oneliner solves this. And it solves it
fast.
It uses just grep,cut,sedand pipes
-
7/27/2019 Lecture #6: Linux basics
7/25
Unix (and Linux)
shellShell is a way to communicate with system.
Shell accepts commands from user (or from script).
Also shells have programming language constructs
(loops, conditionals, variables, etc.)
Most of *nix OS functionality is launched via shell scripts(including windowing system).
-
7/27/2019 Lecture #6: Linux basics
8/25
Unix (and Linux)
first ever login
Whoam I?
Wheream I?
Where is my stuff?
whoami
pwd
ls, cd
-
7/27/2019 Lecture #6: Linux basics
9/25
Unix (and Linux)
users
*nix systems are multiuser
Each user has:
id (UID)
group id (GID)this is defaultgroup
home directory (usually /home/username)
-
7/27/2019 Lecture #6: Linux basics
10/25
Unix (and Linux)
permissionsTo shield users from each other, each file haspermissions
7 4 4
-rwxr--r-- 2 user group ...
filetype
owner
group
others
group
name
owner
name
hardlinks
r (4)- read
w (2)- write
x (1)- execute
-
7/27/2019 Lecture #6: Linux basics
11/25
Unix (and Linux)
directory structureHierarchical organization
Singleroot /
Home directories usuallyin/home
. means current directory
.. means parent directory
-
7/27/2019 Lecture #6: Linux basics
12/25
Unix (and Linux)
directory structure
/bin mission critical binaries
/bootfiles for system boot
/dev device files (yes, devices are seen as files in *nix)
/etc config files (yes, config files are just text files)
/homeusers home directories
/lib mission critical shared libraries
/procprocesses (virtual files)
-
7/27/2019 Lecture #6: Linux basics
13/25
Unix (and Linux)
directory structure
/tmptemporary files
/usr generally, user binaries and libs (sic!)
/varlogs, etc.
FHS for Filesystem Hierarchy Standard
-
7/27/2019 Lecture #6: Linux basics
14/25
Unix (and Linux)
paths & names
path from root is absolute(e.g. /home/username/docs)
path from some dir is relative(e.g. .. fromdocs is
/home/username)
Names:
everything except /, no - at the beginning, but
be careful
-
7/27/2019 Lecture #6: Linux basics
15/25
Unix (and Linux) shell
typical operations
Work with filesdata
Launch programsinstructions
Admin system (well do this later)
You also need to navigatewell start here
-
7/27/2019 Lecture #6: Linux basics
16/25
Unix (and Linux) shell
navigatingls- list directory
useful options: -l -a -A (you can use -la)
cd- change directory
without argument changes to home dircd ~is the same as just cd
-
7/27/2019 Lecture #6: Linux basics
17/25
Unix (and Linux) shell
create files and dirstouch- modify timestamp or create
useful options: -c -a -m
mkdir- create directory
useful options: -p -m (--mode=MODE)
-
7/27/2019 Lecture #6: Linux basics
18/25
Unix (and Linux) shell
look inside filescat- concatenate and print files
useful options: -n -b
head, tail, less- get content of file
head useful options: -c [-]K -n [-]K
tail useful options: -c [+]K -n [+]K -ffile- get file type
useful options: -i -s
-
7/27/2019 Lecture #6: Linux basics
19/25
Unix (and Linux) shell
copy/move files and dirscp- copy files and dirs
useful options: -i -r --preserve[=ATTRS]
be careful: -f
mv- move files and dirsuseful options: -u -i
-
7/27/2019 Lecture #6: Linux basics
20/25
Unix (and Linux) shell
remove files and dirsrm- remove files
useful options: -i -r
be careful: -f
rmdir- remove dirsuseful options: -p
be careful:--ignore-fail-on-non-empty
-
7/27/2019 Lecture #6: Linux basics
21/25
Unix (and Linux) shell
change owners and modechmod- change mode of file or dir
useful options: -R
chown- change owner of file or dir
useful options: -R
-
7/27/2019 Lecture #6: Linux basics
22/25
Unix (and Linux) shell
optionsGeneral syntax:
[OPTIONS] [PARAMS]
Shortkeys:
-k, -k [VALUE]
Longkeys:
--some-long-key[=VALUE]
-
7/27/2019 Lecture #6: Linux basics
23/25
Unix (and Linux) shell
shortcutsCTRL-f, CTRL-b - one char forward/backward
CTRL-a, CTRL-e - to the beginning/end of line
ALT-f, ALT-b - one word forward/backward
CTRL-] x, CTRL-ALT-] x - forward/backward to nextoccurrence of x
!!,!!:p- execute/print last command
!$,!^- last/first argument of last command
-
7/27/2019 Lecture #6: Linux basics
24/25
Lost in translationshell
where to get help?-helpor -h options
man command
(say man ls to get help on lscommand)
aproposcommand
infocommand
/usr/share/doc
-
7/27/2019 Lecture #6: Linux basics
25/25
Questions?
top related