INTRODUCCIÓN A LINUX
INTRODUCCIÓN A LINUX
1 12/4/2019
This class will….
Get your toes wet. Unix and
Linux are gargantuan topics that
only come into focus with
experience.
Provide some basic concept
information for users familiar
with MacOS or Windows.
Get you familiar with Linux
commands.
Get you started in
understanding command line
interfaces.
2 12/4/2019
Class outline
History of Linux
Kernel and shells
The bash shell
Files and directories
File ownership and permissions
Essential Linux commands with exercises
File transfer
Processes
Compressing files
cron
3 12/4/2019
History
Late 60’s through 1980’s
Unix is the result of Bell Labs
research (Dennis Ritchie, Brian
Kerningham, Ken Thompson, et al).
Originally written in assembly
language.
Unics (Unix) was named in contrast
to MIT’s Multics operating system.
Berkeley Software Distribution (BSD),
or Berkeley Unix derived from Bell
Labs’ work in part due to government
monopoly agreements.
Unix led to the BSD family of
operating systems in the 1990’s.
4 12/4/2019
History
Richard Stallman, in 1983
Started the GNU (GNU’s Not Unix!)
project
Open-sourced versions of standard suite
of Unix utilities found in BSD
GNU is also a software license – allows
for code modifications as long as they are
shared
Utilities used in Linux, BSD-derived and
proprietary Unix operating systems
All commands in this lesson are from
GNU
5 12/4/2019
History
Linus Torvalds, in 1991
Released the first version of his Linux
kernel.
Started as a study in processor
architectures while at the University of
Helsinki, Finland, and to this day still
has the authority on what gets
included in the Linux kernel
In 1992 adopted the GNU license and
rapidly gathered developers
Combined the GNU suite of utilities
with a new operating system kernel
(GNU/Linux)
6 12/4/2019
History
By the mid 1990’s/early 2000’s
GNU/Linux starts to gather
main-stream adoption, especially
in research and academic circles
due to structural similarities with
Unix and BSD
Gains large market share of
commercial servers
Becomes usable for desktop
adoption
Present on gadgets (e.g. Android
smartphones, home routers, car
information systems, etc)
7 12/4/2019
Popular Linux Distributions
Red Hat Enterprise Linux
CentOS
Fedora
Debian
Ubuntu
Suse Linux
Linux Mint
8 12/4/2019
Linux in Science (why?)
Popular due to shared functional legacy with Unix systems
associated with research (Irix, SunOS/Solaris, etc.)
Source code availability and semi-liberal licensing made it easy
for researchers to adjust the kernel as needed.
Community backing and “perfect- storm” of enthusiasm for the
project led to critical mass of development (in contract to the
BSD family)
Licensing and well known Unix-style APIs make it easy for
vendors of HPC equipment to write drivers for their hardware.
Wide range of tools available for users (compilers, scientific
libraries, debuggers, etc).
Performance, functionality and portability
9 12/4/2019
Concepts: Kernel
Operating system “kernel” is the core software used to
“talk” to computer hardware
It’s a core and modular system of drivers used to create a
standardized environment for interfacing with hardware
Resource manager for allocating memory and time to
system and user processes as well as interacting with files
(I/O)
Kernel operates in its own memory or “kernel-space”
Users CPU
Kernel Memory
Applications/
processes Devices
10 12/4/2019
Your Shell
On user log-in, the system runs a shell
A shell is the environment within which
you will interface with the kernel via
commands
It determines the syntax for complex
command-line operations and shell
scripting
The shell you’re using is called “bash,” the
successor to the venerable “Bourne Shell”
called “sh”
BASH: “Bourne Again SHell”
11 12/4/2019
Various Shells
sh – the original UNIX shell (Bourne shell)
bash – written as a replacement/extension of
sh
csh – C shell based on the C programming
language developed in the late 1970s
tcsh – enhanced version of C shell
ksh – Korn shell developed in the early 1980’s,
backward compatible with sh, but with some
features of csh
zsh – extended version of sh, developed in
1990
dash – developed as replacement for ash in
Debian
12 12/4/2019
Linux accounts
To access a Linux system, you need to have an account
A Linux account includes the following:
- username and password
- uid and gid
- a home directory, which is where you are placed by
default when you log in
- a default shell
13 12/4/2019
Using SSH to log in:
14 12/4/2019
Logging in
MacOS:
Finder -> Applications -> Utilities -> Terminal
Now type: “ssh [email protected]”
At the prompt, enter the account password
Windows:
Launch PuTTY. Under “Host Name (or IP address), type:
[email protected]
…and click “Open”
At the prompt, enter the account password
15 12/4/2019
Logging out
DON’T run this now, but to log out of a ssh session on a
Linux system, you would type exit:
$ exit
16 12/4/2019
More on shells
What shell am I in? Typing “echo $SHELL” will show you!
You should see ‘/bin/bash’
Typing “echo $0” will also show your shell
$SHELL and $0 are shell variables…more about variables
later
List of available shells on the system can be displayed by
typing “chsh --list-shells”
The chsh command can be used to change your default
shell as well, but on Biowulf & Helix never change it to a
shell that ends in LOCKED, SUSPENDED, DISABLED –
you will lock yourself out of your account!
17 12/4/2019
Shell preferences
When you login, startup scripts are run to setup your
environment
For bash, you can customize your environment by adding or
modifying environment variables and aliases in the .bashrc
file in your home directory.
Examples:
alias ls=‘ls -rtl’
alias bwulf='ssh [email protected]'
PATH=$PATH:/data/myusername
EDITOR=/usr/bin/vim
PS1="[\u@\h \w \# ]"
set -o noclobber
18 12/4/2019
Summary of Linux commands
awk allows manipulation of text more scroll through file a page at a time
bg place suspended job into background mv change the name of a file (move)
cal display calendar nano/pico text editors
cat view contents of a file printenv display shell variables
cd change directory
ps show current process information
chmod change permissions on a file/directory
pwd print current working directory
cp copy a file
rm delete or remove a file
cut extract a field of data from text output
diff compare files line by line rmdir delete or remove a directory
echo output text to the terminal or to a file sed stream editor
emacs text editor sleep pause
fg bring suspended job to foreground sort perform a sort of text
file display file type tail view end of the file
find search for files touch create an empty file or update timestamps
grep search a file or command output for a pattern tr character substitution tool
head view beginning of file uniq remove identical, adjacent lines
history display list of most recent commands
vi/vim text editor
less scroll forward or back through a file
wc print number of lines, words or characters
ln create a link to a file
which shows full path of a command
ls list files in a directory
whoami displays username
man view information about a command
mkdir make directory
19 12/4/2019
Our cast! (of characters)
Character Name/Location
\ Backslash (above the enter key)
/ Slash (left of right shift key)
` Back-tick (left of the number 1, above the tab key)
| Pipe (shift-\)
[ and ] Brackets (left of the backslash)
{ and } Braces or “curly” brackets (shift-[ and shift-])
< and > Angle brackets (left of the right shift key)
~ Tilde (shift-~)
!, @, #, $, (!) Bang/exclamation mark, (@) at sign, (#) hash, ($)
%,^, &, *, dollar/string, (%) percent, (^) caret, (&) ampersand, (*)
(, ) asterisk/start, and the left and right parenthesis.
20 12/4/2019
Linux Command Basics
Linux commands are case-sensitive
ls is not the same as LS
Linux commands may have options that come after the
command that start with a “–” and followed by a letter or “- -”
and a word:
$ ls –r
$ ls --reverse
Linux commands may allow for arguments:
$ ls /tmp
You can run more than one command on the same line by
separating the commands with a semicolon (;)
$ ls;date
Most Linux commands have a manual page or help to describe
how they can be used….more about this later!
21 12/4/2019
Linux Command Example
prompt
command
option
argument
$ ls –r /home/$USER
22 12/4/2019
Exercise #1: First commands
[username@helix ~]$
Type “whoami”, press Enter – who are you?
Type “pwd”, press Enter – where are you?
23 12/4/2019
Concepts: Files and Processes
In Unix, and by extension, Linux,
everything is either a file or a process.
Meaning everything can be interfaced via
the file system(s).
Files: text, data, documents, traditional
files
Directories: directories are special text
files that contain a bunch of other files
Devices: all disks, video hardware, audio
hardware, processors, memory, USB
ports – all hardware can be interfaced
via files (usually in /dev)
Processes: all running processes can be
“seen” via the file system (in /proc) –
each has a unique identifier (PID)
24 12/4/2019
More on Files
Each file (and directory) has a name
The filename can contain letters, numbers and special
characters – best to start with name or number
Every file has a unique path to its location
Example: /home/student2/read-write.txt
A filename MUST be unique within a directory…though
files with the same filename can exist in different
directories
Like Linux commands, filenames are case sensitive so a
file named “myfile” and “Myfile” can co-exist in the same
directory – the names are different.
Filenames can be lengthy
25 12/4/2019
More on Directories
A directory is a special type of file that can hold other files –
often referred to as a folder in Windows or MacOS
The “working directory” is the directory with which your shell
is currently associated…where you currently are! When you
first login, you will normally be in your home directory,
/home/username
/home/student2/Projects/docs/final_report.doc
27 12/4/2019
Concepts: The File System
28 12/4/2019
Linux Directory Structure
/ root
/bin bare essential commands
/boot OS Kernels
/dev hardware devices
/etc system files, configuration
/home home directories
/lib Libraries needed by the system
/opt 3rd party applications
/proc Running processes
/sbin administrative commands
/tmp temporary space
/usr operating system applications
/var Logs, databases and other variable length stuff
29 12/4/2019
cd and ls commands
The “cd” command is used to change directory location. Without an
argument, “cd” takes you to your home directory
The “ls” command is used to list the files in a directory. Like many Linux
commands, it can take a number of “flags” as options to change the behavior
of the command
$ cd /home/$USER
$ ls
$ cd /etc
$ pwd
$ ls
$ ls –l
$ ls -rl
$ cd
$ pwd
30 12/4/2019
Exercise #2: “cd” and “ls” commands
Type “cd /data/classes/linux”
Try “ls -l”
Try “ls -a”
Try “ls -la”
How are the above outputs different?
Type “ls –lt”
How is this output ordered?
Type “ls –l /tmp”
The above shows how providing an argument to the ‘ls’ command displays
the contents of a directory without first changing to the directory
Type “cd /home/$USER” to change to your home directory
Now type “cd -”
To what directory did that take you?
Now type “cd ..”
To what directory dis that take you?
Type “cd /home/$USER” to get back to your home directory
31 12/4/2019
Finding your way home!
The “~” is a special character that is short-hand for
“/home/username”
The shell variable $HOME also stores the path of
“/home/username”
Several ways to get to your home directory:
$ cd ~
$ cd $HOME
$ cd /home/username
$ cd /home/$USER
$ cd
But you can also use the “~” and $HOME as arguments with
other commands:
$ ls ~/tmp
$ ls $HOME/LinuxClass
32 12/4/2019
Absolute and Relative paths
The starting “/” in the $ cd /home/username
directory argument explicitly
# Absolute path:
spells out a pathname –
$ cd /home/username/tmp
specifying an absolute or full
path # Relative path:
$ cd tmp
No leading “/” means you are
specifying a path that is # Using ~
relative to the current
working directory. These do the same:
$ cd ~/tmp
“cd /tmp” is different from $ cd /home/username/tmp
“cd tmp”
33 12/4/2019
Help!
Many commands provide a ‘--help’ option which will display information on
the various options and there means. For example:
$ ls --help
There is also the “man” command, which will provide a manual listing on
the use of standard Linux commands such as ls one page at a time
$ man ls
One can scroll forward or back one line at a time using the up & down
arrow keys and scroll forward or back one page at a time by hitting the ‘f’
or ‘b’ keys, respectively.
Exit out of a man page by typing ‘q’
Try both of the above commands
34 12/4/2019
Users and Groups
Users are associated with a unique
user identification (UID) number
that the system uses internally
Users can be real people
Users can be system entities
Users can be herded via groups
Groups also are associated with a
unique group identification (GID)
number by the system
Groups allow multiple users to
access/share the same files
35 12/4/2019
Ownership & Permissions
Linux systems are multi-user environments that allow users to
create files, run programs and share data.
Files and directories have two types of ownership – the user and
group. A Linux group consists of one or more users.
Every file and directory has permissions for three levels or entities
of permissions:
a) user or owner (denoted by u)
b) group (one or more users – denoted by g)
c) others or world (denoted by o)
36 12/4/2019
Permissions triplets
Each triplet indicates the access permissions for that level – in
the example below, the user/owner has read, write & execute
permission, other group members only have read and execute
permissions and all others have no access permissions.
-rwxr-x---.
37 12/4/2019
Long List Output Explained (a little)
From left to right: $ ls -la
drwxrwx--- 104 mark staff 110592 Aug 17 13:02 .
Owner
-rw-rw-r-- 1 david staff 20529 Aug 7 2017 httpd.conf
• -rwxr--r-- 1 root staff 136236 Sep 10 2017 memcon
drwxr-x--- 2 mark staff 4096 Jun 24 2017 misc
Modification date
lrwxrwxrwx 1 mark staff 7 Aug 16 15:30 year2 -> year.pl
•
• Name of file
Special Directories:
• . is the current working directory
• .. is the “parent” directory, one level “back”
38 12/4/2019
Permissions described:
39 12/4/2019
Changing Permissions and Ownership
Use ‘chmod’ to change the file permissions:
chmod [ugoa][+/-][rwx] filename
where u=user, g=group, o=others or world and a=all three
For example, to provide group read access to a file:
$ chmod g+r myfile
Or to remove file access to another than the owner or group members (in other
words, others):
$ chmod o-rwx myfile
The ‘chown’ command is used to change file ownership and the ‘chgrp’ command
can change group ownership of a file. As a regular user, you can not change
the ownership of a file, but you can change the group ownership if you
are a member of the group to which you are changing the group
ownership
You can use the –R argument on any of the above to recursively make changes on a
directory of files
40 12/4/2019
Exercise #3 pre-exercise
We’ll talk about some of these commands shortly, but you each need
to make a copy of files needed for the rest of class.
42 12/4/2019
Wildcards
With many Linux commands, you can use wildcards to match
characters
ESC
Back
tick
Tab
Single
quote
Arrow
Ctrl keys
44 12/4/2019
Ctrl-c, ESC & command line editing
If you get into a situation where you can’t seem get back
to a command line prompt, try hitting the Ctrl-C
combination or the Esc key – often one of those will
abort whatever you are currently doing.
The Ctrl character is often represented by the ^
45 12/4/2019
What is that file?
file
The “file” command tells us what type of file it might be
– text, executable, PDF, jpg, gzip, tar, directory, etc.
$ file read-write.txt
$ file world.exe
$ file examples
$ file Linux_slides.pdf
46 12/4/2019
cat and echo
47 12/4/2019
Output Redirection to Files
48 12/4/2019
Exercise #4: cat and echo
Using echo
$ echo my name is Chris
$ echo “my name is $USER” > myname
$ cat myname
$ echo Hello $USER >> myname
$ cat myname
49 12/4/2019
Symbolic links
Example:
$ ln –s /home/$USER/LinuxClass/examples/tmp/colors color-pairs
$ ls –la color-pairs
$ cat /home/$USER/LinuxClass/examples/tmp/colors
$ cat color-pairs
50 12/4/2019
Creating files/directories
Using touch and mkdir
To create a directory:
$ mkdir Mydirectory
$ mkdir 2017
$ mkdir –p 2018/Jan/stats
51 12/4/2019
Deleting files/directories
To remove a directory:
$ rmdir Mydirectory
$ rm –r 2017
Dangerous:
$ rm –rf *
52 12/4/2019
Exercise #5: Creating and deleting files
Creating a file, directory & symbolic link
$ cd /home/$USER/LinuxClass
$ echo ‘I love genomic research!’ > science
Now create a file named science_project and a directory named
scienceclass (hint: use touch & mkdir)
$ ls –ld science*
$ ln –s “/home/$USER/LinuxClass/examples/tmp/ice_cream” Ice_cream
$ ls –la Ice_cream
$ cat Ice_cream
“more” or “less”
$ more mascots.txt
$ less mascots.txt
- each prints out a page of a file at a time
“head” or “tail”
$ head mascots.txt
- prints out the first 10 lines by default. Can use the
–n argument to change the default number of lines
54 12/4/2019
Text editors
55 12/4/2019
nano – a simple editor
$ nano filename
The essentials:
Just start typing – can use arrow keys to position,
backspace or delete key to delete characters to the left
Keystrokes for basic commands at bottom of the screen
^G – help screen (^C to exit help)
^O – save the file
^W – search for a string
^X – exit nano
$ nano --help
56 12/4/2019
Exercise #6: Editing a file using nano
$ cd /home/$USER/LinuxClass
$ nano bashrc
1) Using the RIGHT arrow key, position the cursor at the end of the first line,
2) Use the Backspace key to remove <HOMEDIRECTORY> from the first
line and then type $HOME after the colon
3) Hit Ctrl-W (to search), type NANOPATH and hit Enter – this should place
you on the last line
4) Hit Ctrl-E to get to the end of the line
5) Use the Backspace key to remove everything after the ‘=‘ sign and type
‘/bin/nano’
6) Use the up & the right arrow keys to get to the @ on the 2nd line
7) Backspace to remove <USERNAME> and type your username
8) Use the down arrow key to get to the 3rd line
9) Hit Ctrl-K to cut the 3rd line
10) Hit the Up arrow to get to the 1st line & Ctrl-A to get to the start of the line
11) Hit Ctrl-U to paste the text – the 3rd line should now be the first
12) Hit Ctrl-X to exit – type Yes to save the file when prompted and hit Enter
when prompted for the name
$ cat bashrc
57 12/4/2019
mv - moving files/directories
mv - move one or more files or rename a file (some
Linux versions have a ‘rename’ command, but not all):
Syntax: mv source destination
$ touch football
$ touch footballgame
$ ls –l football*
$ mv footballgame footballtee
$ ls –l football*
$ mkdir sports
$ mv sports Sports
$ ls –ld *ports*
$ touch footballtee2
$ mv footballtee* Sports
$ ls –la Sports
58 12/4/2019
cp - copying files/directories
$ cp football football2
$ cp –p football football3
$ ls –la football*
$ cp –p Sports/footballtee .
$ mkdir –p Sports/fall
$ cp –p football2 Sports/fall
$ cd Sports/fall
$ cp –p football2 ../football4
$ cd ..
$ ls –R Sports
Archival copy:
$ cp –a Sports Sports2017
$ cp –pr Sports Sports2018
59 12/4/2019
Exercise #7: Moving/Copying Files
Move (mv) Copy (cp)
$ cd /home/$USER/LinuxClass $ cp raspberry strawberry
$ touch Raspberry $ cp –p raspberry cranberry
$ mv Raspberry raspberry $ ls –la *berry
$ echo blueberry > blueberry How do the four *berry files differ?
$ ls –la *berry $ mkdir –p BERRIES/Others
Now create a directory path using $ cp –p *berry BERRIES/Others
mkdir with the –p option: $ mv *berry BERRIES
$ mkdir –p Berries/All/B $ ls –la BERRIES
Use mv to move the blueberry file $ cp –pr BERRIES/Others BERRIES/More
into Berries/All/B directory:
$ ls –Rla BERRIES
$ mv blueberry Berries/All/B
$ touch Berries/All/B/blackberry $ cp BERRIES NewBerries
$ mv Berries/All/B/blackberry . What did you see?
$ mv Berries BERRIES $ cp –pr BERRIES NewBerries
$ ls -Rl Berries Archival copy:
$ ls –Rl BERRIES $ cp –a BERRIES Berries-save
60 12/4/2019
wc - what’s in that file?
“wc” (word count)
$ wc mascots.txt
345 955 7342 mascots.txt
Output shows the number of lines, words and characters in
the file
$ wc –l mascots.txt
$ wc –w mascots.txt
$ wc –m mascots.txt
$ wc -help
61 12/4/2019
grep – pattern matching search of a file
65 12/4/2019
uniq – show or remove duplicate lines
66 12/4/2019
Sorting
sort command
67 12/4/2019
Pipes (redirect to other processes)
68 12/4/2019
Exercise #10: sort, pipes and redirection
cd /home/$USER/LinuxClass
Look at the contents of two files, grocery1 and grocery2
(use cat command)
Combine the two files using the cat command and then
use the sort and uniq commands to get a list of sorted,
unique items for the grocery list
Now redirect the output to a file named grocery3
Use the wc command to determine how many unique
items are on the list (in the grocery3 file).
Use grep and wc to determine how many items in the
grocery3 list start with the letter ‘c’
69 12/4/2019
Exercise #10 continued
$ cat grocery1
$ cat grocery2
$ cat grocery1 grocery2 | sort | uniq
$ cat grocery1 grocery2 | sort | uniq | wc –l
You should have 32 items
$cat grocery1 grocery2 | sort | uniq > grocery3
$ grep ^c grocery3
7 items start with the letter c
70 12/4/2019
Other useful commands
71 12/4/2019
date & cal
72 12/4/2019
Input, Output and Error
73 12/4/2019
Input, Output and Error (cont)
STDIN, STDOUT and STDERR have handles or numbers associated
with each:
Handle
STDIN 0 Standard input
STDOUT 1 Standard output
STDERR 2 Standard error
Let’s change permissions on dogs2 to be unreadable:
$ cd $HOME/LinuxClass
$ chmod ugo-r dogs2
Can redirect the STDERR to a file:
$ grep dog dogs* 2> errors
$ grep dog dogs* 2> /dev/null
Can redirect BOTH the STDOUT and STDERR to a same file:
$ grep dog dogs* > out_plus_errs 2>&1
or to different files:
$ grep dog dogs* > OUTPUT 2> ERRORS
74 12/4/2019
Putting it all together
75 12/4/2019
awk – text manipulation
78 12/4/2019
More Linux Command Basics…Quotes
$ which date
$ which whoami
$ which perl
80 12/4/2019
Shell Variables
81 12/4/2019
Shell Variables
Show all currently assigned Useful predefined and
variables important variables
$ printenv $HOSTNAME System hostname
HOSTNAME=biowulf.nih.gov $USER Your Username
TERM=xterm $SHELL Your shell
SHELL=/bin/bash $HOME Home directory
HISTSIZE=500 $PWD Current directory
SSH_CLIENT=165.112.93.227 $PATH Command paths
49886 22
OLDPWD=/home/mark
HISTFILESIZE=500
USER=mark
…
82 12/4/2019
Loops
“For” loops allow for iteration Perform math using the seq
based on flow control criteria command:
$ for n in 1 2 3 4 5 6 7 $ seq 1 10
> do
> echo The value of n is $n $ t=0
> done $ for n in `seq 1 10`; do
> t=`expr $t + $n`
$ for n in {1..7} > echo $t
> do > done
> echo The value of n is $n $ echo $t
> done 55
84 12/4/2019
Logic tests
$ if [ -d $HOME/LinuxClass ]
$ if [ “$TRUE” = “no good” ]
> then
> then
> echo “true statement” > echo true
> else > fi
> echo “false statement”
> fi
85 12/4/2019
File Transfer
86 12/4/2019
WinSCP
• Start WinSCP
• Click “New”
• Click Login
87 12/4/2019
WinSCP Interface
• Left window is your
local workstation, right
window is the remote
host
• Navigate like a
traditional explorer
interface
88 12/4/2019
Using OpenSSH (Unix/Linux/MacOS)
As usual
$ scp --help
$ man scp
89 12/4/2019
File Transfer via HPCdrive
90 12/4/2019
Globus
91 12/4/2019
Exercise #11: Using scp
Type ‘exit’ to log off from Helix and get back to your local
system:
$ exit
Use scp to copy the file read-write.txt from Helix to your local
system – NOTE the trailing space & period in each
command!
$ scp [email protected]:/data/classes/linux/read-write.txt .
Reconnect to helix via ssh once the file transfer has been completed
92 12/4/2019
Processes
Show processes
$ sleep 25 &
$ ps -f
$ ps –f --forest
95 12/4/2019
Processes: kill them
96 12/4/2019
Exercise #12: Using ‘kill’ on a process
First start a ‘sleep’ process that will run in the background for 300
seconds:
$ sleep 300
Type ‘Ctrl-z’ (the Ctrl and z keys together) to suspend the ‘sleep’
process
Type ‘bg’ to unsuspend the ‘sleep’ process and have it run in the
background.
Check that the process is running by using the ‘ps’ command and
note the pid, process identification number
Using the ‘kill’ command with the pid of the sleep process from the
previous step, terminate the sleep process
How can you check that the sleep process is gone?
97 12/4/2019
uptime
98 12/4/2019
Who is doing what…using top
100 12/4/2019
Directory size
Summary:
$ du -s LinuxClass
Default behavior:
$ du
101 12/4/2019
Checking Quotas on Helix/Biowulf
“checkquota”
102 12/4/2019
tar & gzip
The tar command allow users to compress and archive files – does not remove the
original files by default
Syntax for tar to create an archive:
$ tar –czvf <output file> <files to be archived>
where c is to create
z is to compress using gzip
v is verbose output (lists files as they are tar’d)
f indicates that the next argument is the output filename
Syntax to extract files from an archive:
$ tar –xzvf <filename>
Syntax to list the files in a tar file:
$ tar –tzvf tarfile.tar.gz
The gzip command is similar, but the original file is removed unless you specify to
keep it with the ‘-c’ option.
Example:
$ gzip files.gz
103 12/4/2019
Cron
Cron: run a job whenever you want
crontab -l
crontab –e
--
15 3 * * * ~/script.sh >> ~/output 2> ~/error.log—
* * * * *
First number is the minute at which to run (0-59)
Second is the hour (0-23)
Third is the day of the month (1-31)
Fourth is the month (1-12)
Fifth is the day of the week (0-6), 0 is Sunday
104 12/4/2019
Review
History – Linux Torvalds, 1991
Why Linux? Performance, functionality and portability
Bash shell & shell variables
Files and directories – permissions & ownership
Linux file system
Paths to files/directories
Basic Linux commands to create & access files & directories
nano editor
sort, grep & find
pipe & file redirection
awk, sed, & tr text manipulation utilities
transferring data to & from a Linux system
processes
cron
105 12/4/2019
Resources
Linux Documentation Project: http://www.tldp.org
Introduction to Linux - A Hands on Guide:
http://www.tldp.org/LDP/intro-linux/html/index.html
106 12/4/2019
Questions? Comments?
107 12/4/2019