0% found this document useful (0 votes)
101 views

Linux Administration (Admin 1)

Study Material

Uploaded by

mohammedb.kassab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
101 views

Linux Administration (Admin 1)

Study Material

Uploaded by

mohammedb.kassab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Linux Administration

Azza Khalil
[email protected]
Azza Khalel | LinkedIn
About me
Objectives
• What is Linux OS?
• Linux administration AdminI and AdminII
Day1 contents
• What’s Linux?
• OS objectives
• Linux advantages
• Linux and unix distribution
• Linux components
• Linux tree
• Linux paths
• Installing Linux
• Linux basic commands
• File and dir management.
• Linux vi editor
• Reading files
• Search in Linux
• Terminal shortcuts
What is Linux?
• OS objectives:
• HW management
• Basics of any application.

• Linux is an open-source operating system under the GNU/GPL license.

• Linux advantages
• Linux is open source.
• Linux is secure and virus free.
• Linux is perfect for programmers.
• Linux has a better community support.
• Linux is reliable.
• Linux has better performance
Linux and unix distribution
• Unix distributions:
• Oracle: Solaris
• IBM:HIX
• HP:HP/UX
• Silicon Graphics:IRIX

• Linux distributions:
• Redhat: Redhat server(updated each 18 months), Centos(free),
Fedora(updated each 6 months)[testing]
• Ubuntu: Debian[stable], Ubuntu[testing]
• Novell: SUSE[stable], OpenSUSE[testing]
• Minit
Linux components
• Kernel
• Is the core of the operating system.
• Contains components like device drivers.
• It loads into RAM when the machine boots and stays resident in RAM until the machine
powers off.
• Shell
• Provides an interface by which the user can communicate with the kernel.
• The shell parses commands entered by the user and translates them into logical segments
to be executed by the kernel or other utilities.
• There are lot of shells as :
• Bourn Shell (sh)
• Korn Shell (ksh)
• C Shell (csh)
• Bourn Again Shell (bash) ➔ is the most commonly used shell on Linux
• They have different features that will be discussed later
• Terminal
• Gives the shell a place to accept typed commands and to display their results.
Linux filesystem tree
/

etc tmp home root dev bin sbin usr var

• Some important files under these directories:

• /etc/passwd
• /etc/group
• /etc/shadow
• /usr/bin
• /usr/sbin
• /var/spool/mail
• /var/log
Linux paths
• Absolute path
• Is the full path from / to the place where you need.
• Relative path
• Is the path from your current place to the place where you need

Note:
. => means current directory
..=> means parent directory
Linux Command syntax
• command
• command -<option>
• command -<option> <argument>
• command -<option> <file>

• Make sure from


• Spelling
• Case
• Spaces
• Syntax
Install centos9
Linux basic commands
• Print system info
• #uname
• #uname –n
• #uname -a
• Display a calendar
• #cal
• #cal [month] [year]
• #cal [year]
• Print or set the system date and time
• #date
• #date +%B ➔ to print only the current month
• Print effective user
• #who ➔ print tty (user physically login) and pts (user who open shells)
• #whoami ➔ print the effective user who access now
• #who am I ➔ print the user whose firstly login the machine
• #id ➔ displays effective user_id, effective username, effective group_id, effective group_name.
• #w ➔ display a summary of the current activity on the system, including what each user is doing
Directories
• Changing directories
• #cd /home/user1/work
• #cd ..
• #cd ~
• #cd -
• Listing directory contents
• #ls
• #ls -l
• #ls –ld
• #ls –i
• #ls –R
• #ls –a
• #dir --color
• Printing current directory
• #pwd
• Directory creation
• #mkdir
• #mkdir -p
Files
• File naming
• File names may be up to 255 characters.
• There are no extensions in Linux.
• Avoid special characters as >< ? * # '.
• File names are case sensitive.

• File creation
• #touch

• Viewing File content


• #cat fname
• #more fname
• Scrolling keys for the more command

• Spacebar: moves forward on screen.

• Return: scroll one line at a time.

• b: move back one screen.

• /string: search forward for pattern.

• n: find the next occurrence.

• q: quit and return to the shell prompt.

• #head -n fname
• #tail -n fname
• #tail –f
• #wc [wc -l, wc -w, wc -c]

• File globing
• Asterisk(*) ➔ ls f* ls *3
• Question mark(?) ➔ ls f? ls ?3
• Square bracket([]) ➔ ls [a-f]* ls [af]*
vi text editor
• Vi editor (visual editor) is the default editor for Unix and Linux OS.
• Vi is used to manage file content.
• Vi is an interactive editor that you can use to create and modify test files.
• Usually, the only editor available in emergency mode.
• vi in Linux is usually vim (vi improved):
• Syntax highlighting.
• Arrow keys, Del, BS work in insert mode.
• Mouse support.
• An advantages of this editor is that we can manipulate text without using a
mouse. We can only need the keyboard.
• Vi has 3 basic modes
• command mode (Default mode, Perform commands to delete, copy, ....)
• Edit (insert) mode➔ Enter text into the file
• Last line mode ➔ To access it, enter a colon (:) while in the command mode
vi text editor operations
• The syntax of vi command:
• #vi <filename>
• To recover a file
• #vi -r filename
• Viewing files in Read-only mode:
• #view filename
• Perform the :q command exit.
• Inserting and appending text:
• i ➔Inserts text before the cursor.
• o ➔Opens a new blank line below the cursor.
• a ➔Appends text after the cursor.
• A ➔append text at the end of the line.
• I ➔insert text at the beginning of the line.
• O ➔opens a new line above the cursor.
• After editing Press esc to enter command mode.
• Moving the cursor within the vi
• e ➔ to the end of the current word.
• 0 ➔ to the beginning of the line.
• $ ➔ to the end of the line
• G ➔ to the last line in the file
• 1G ➔ to first line in the file
vi text editor operations
• Save and quit
• :w ➔ save the file.
• :w new_file ➔ save as new file.
• :wq, ➔ save and quit.
• :q! ➔ quit without saving.
• Search and replace
• /string ➔ Searches forward for the string.
• ?string ➔ Searches backward for the string.
• n ➔ Searches for the next occurrence of the string.
• N ➔ Searches for the previous occurrence of the string.
• %s/old/new/g ➔ Searches for the old string and replaces it with the new string
globally.
• Customization vi session
• set nu, :set nonu ➔ show and hide line numbers.
File and dir manibulation
• Copying files and dirs.
• #cp <source_file> <destination_dir>
• #cp –r <source_dir> <destination_dir>
• #cp –i ➔ Prevents you from accidentally overwriting existing files or dirs
• #scp <source_file> <user>@<remote_host>:<destinamtion_dir>
• Moving and renaming files
• #mv <source_file> <destination_dir>
• Remove files and dirs.
• #rm <file_name>
• #rm –f <file_name>
• #rmdir
• #rmdir –p
• #rm –r
• #rm -rf
Linux documentation
• Linux has more sections for its documentation
• Section 1 ➔ to search for user commands
• Section 5 ➔ to search for configuration files
• Man command
• #man cat ➔ search about cat in the first section it's exits
• #man –f passwd ➔ to show passwd exist in which section
• #man –a passwd➔ to search about passwd in all sections
• man –s5 passwd➔ search about passwd in section5 only
• man –k calender➔ search by any keyword
Linux documentation
• Manual page consists of
• Name
• The name of the command and a one-line description.

• Synopsis
• The syntax of the command

• Description
• Explanation how the command works and what it does

• Files
• The file used by the command.

• Bugs
• Known bugs and errors.

• See also
• Other commands related to this one.
Terminal shortcuts
• TAB completion
• \ ➔ if we have a many lines command

You might also like