0% found this document useful (0 votes)
13 views18 pages

redhat admin

The document provides a comprehensive overview of Red Hat administration, covering Linux history, installation types, user and group management, permissions, and the use of the Vi text editor. It details various commands for process management, file handling, package management, and text processing. Additionally, it includes information on environment variables, command history, and archiving and compression techniques.

Uploaded by

narasingam9807
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)
13 views18 pages

redhat admin

The document provides a comprehensive overview of Red Hat administration, covering Linux history, installation types, user and group management, permissions, and the use of the Vi text editor. It details various commands for process management, file handling, package management, and text processing. Additionally, it includes information on environment variables, command history, and archiving and compression techniques.

Uploaded by

narasingam9807
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/ 18

RedHat admin

Day 1
1. Linux History

●​ Originated from Unix (1969).


●​ Linux kernel created by Linus Torvalds in 1991.
●​ Various distributions (distros): Ubuntu, Red Hat, Fedora, etc.

2. Why Red Hat?

●​ Used by 90% of Fortune Global 500.


●​ Secure, scalable, and backed by professional support.

3. Types of Linux Installation

●​ Kickstart: Automated
●​ Graphical
●​ Text-based

4. Linux Components

●​ Kernel: Core OS component.


●​ Shell: Interface between user and kernel (bash is most common).
●​ Terminal: Interface to type and view commands.

5. Shell Types

●​ sh, ksh, csh, bash


Command Explanation

command [options] General command structure


[arguments]

uname Displays system name

uname -n Hostname of the system

uname -a All available system information

cal Calendar for current month

cal 5 2004 Calendar for May 2004

date Displays current date and time

Ctrl + c Interrupts a running command

Ctrl + d Ends input or logs out

man -k keyword Search manual pages by keyword

man -s keyword Manual section for keyword

whatis command One-line description of a command

command --help Show help for command

pwd Show current directory

cd /path Change to specified directory

cd .. Go up one directory

cd ~ Go to home directory

cd - Go to previous directory
ls List directory contents

ls -a Show all files including hidden ones

ls -l Long listing with permissions, size, etc.

ls -F Adds symbols to indicate file types

ls -ld dir Show details of the directory itself

ls -R Recursively list subdirectories

cat filename Show file content

more filename Scroll through file content

head -n filename Show first n lines of file

`tail [-n +n] filename`

touch filename Create an empty file

mkdir dir Create a new directory

mkdir -p dir/dir2 Create nested directories

rm filename Delete file

rm -i filename Ask before deletion

rm -r dirname Delete directory and contents

rmdir dirname Delete an empty directory

cp source target Copy file

cp -i Ask before overwriting file

cp -r Copy directory recursively

mv source target Move or rename file


Day 2
1. User and Group Administration

●​ User files: /etc/passwd, /etc/shadow, /etc/group, /etc/gshadow


●​ User creation: useradd, passwd, newusers
●​ User modification: usermod, chage
●​ User deletion: userdel
●​ Group management: groupadd, groupmod, groupdel, gpasswd, newgrp, groups

2. Permissions & Ownership

●​ File/Dir ownership managed using chown


●​ Permissions controlled with chmod
●​ Defaults managed using umask

3. Switching Between Users

●​ su, whoami, id, who, w, finger, sudo

4. Shutdown and Virtual Consoles

●​ Commands for shutdown, reboot, and virtual console usage

Command Explanation

useradd username Adds a new user

passwd username Sets the user's password

useradd -D Shows default useradd settings

newusers filename Creates multiple users from file

usermod -l newname oldname Changes a username


usermod -L username Locks the user's password

usermod -U username Unlocks the user's password

userdel [-r] username Deletes a user (and optionally home


directory)

chage [options] username Manages password aging policies

groupadd groupname Creates a new group

groupmod [options] Modifies an existing group


groupname

groupdel groupname Deletes a group

find / -nogroup Lists files with no valid group

gpasswd Manages group members/admins

newgrp group Switches to another group you're a


member of

groups Lists groups you belong to

su [-] [username] Switches user

su [-] [username] -c command Executes command as another user

whoami Shows the current effective user

id Shows UID, GID, and groups of the


current user

id username Shows UID, GID, and groups of a


specific user

who Shows who is logged in


w Shows system usage and who is doing
what

finger Shows user info

sudo Executes a command as another user


(usually root)

visudo Edits the sudoers file safely

chown user file Changes file ownership to user

chown user:group file Changes file owner and group

chmod [modes] file Changes file permissions

chmod u+x file Adds execute permission to the user

chmod a=rw file Sets read/write for all

chmod 755 file Sets permissions in octal

umask Displays current default permission


mask

umask 002 Sets default file permission mask

Ctrl+Alt+F1 to F6 Switch to virtual consoles

shutdown -k now Sends shutdown warning only

shutdown -h now Shuts down and halts system

poweroff Powers off system

init 0 Shuts down the system

Day 3
1. Vi Text Editor
●​ Powerful, default text editor in Linux/Unix systems.
●​ Three modes:
○​ Command mode – for deleting, copying, navigation.
○​ Insert mode – for editing/inserting text.
○​ Last line mode – for saving, searching, advanced commands.

2. Initialization Files

●​ Global:​
/etc/profile, /etc/bash.bashrc
●​ User-specific:
○​ ~/.profile, ~/.bash_profile, ~/.bash_login, ~/.bashrc

3. Environment Variables

●​ Examples: $HOME, $PATH, $PWD, $SHELL, $USER, $HOSTNAME

4. Aliases and Command History

●​ Create, list, or remove aliases.


●​ Recall and repeat previous commands with history.

VI EDITOR COMMANDS WITH EXPLANATIONS


Command Function

vi filename Open file in vi

vi -r filename Recover unsaved file

view filename Open in read-only mode

Insert Mode Shortcuts

Key Action

i Insert before cursor

a Append after cursor


o Open new line below

O Open new line above

A Append at end of line

I Insert at beginning of line

Cursor Movement

Key Action

h, <-, Backspace Left

l, ->, Space Right

j, Down Arrow Down

k, Up Arrow Up

w Next word

b Previous word

e End of word

0 Beginning of line

G End of file

nG / :n Go to line number n

Ctrl+F/B Scroll forward/back

Ctrl+L Refresh screen

Editing Text

Key Action

s Replace character
x Delete character

dw Delete word

dd Delete line

D Delete to end of line

n,nd Delete lines n through n

Search & Replace

Command Function

/text Search forward

?text Search backward

n, N Next/previous match

:%s/old/new/g Global replace

Copy & Paste

Command Function

yy Yank line

p, P Paste after/before line

n,n co n Copy lines to line n

n,n m n Move lines to line n

Save & Quit

Command Function

:w Save

:w new_file Save as new file

:q! Quit without saving


:wq, :x, ZZ Save and exit

Customization

Command Function

:set nu / :set nonu Show/hide line numbers

:set ic / :set noic Case insensitive/sensitive

:set showmode Show mode info

SHELL & BASH COMMANDS

Environment Variables

Variable Description

$HOME Home directory

$PATH Executable paths

$PWD Current directory

$SHELL Current shell

$USER Current user

$HOSTNAME System name

echo $VAR Show value of VAR

set Show all variables

ALIAS COMMANDS
Command Explanation

alias ll='ls -l' Create alias for ls -l


alias Show all aliases

unalias name Remove alias

\command Run command without alias

COMMAND HISTORY USAGE


Command Function

!! Repeat last command

!string Repeat last command starting with "string"

!n Run command by number

!-n Run n commands back

^old^new Replace text in previous command

Day 4
1. Processes, Priorities, and Signals

●​ Process: Program running on CPU, has a PID.​

●​ Daemon: Background process.​

●​ Parent & Child: Parent process creates child process.​

●​ Priority/Niceness:​

○​ -20 (highest priority) to +19 (lowest).​

○​ Users can only lower their process priority (+19); root can raise it (-20).​

2. Redirection
●​ Redirect standard output, input, and error.​

●​ Combine output and errors.​

3. Pipelines

●​ Use | to send output of one command as input to another.​

4. Word Count and String Processing

●​ Using wc, diff, grep, cut, tr, sort for text and file processing.​

COLLECTED LINUX COMMANDS & THEIR


EXPLANATIONS

Process Management

Command Explanation

nice [-n adjustment] Start a process with a specific niceness


command

nice -n 20 makewhatis Example: start makewhatis with niceness +20

renice priority -p PID Change priority of a running process

ps [options] Show process status

ps -e List all system processes

ps -f Full details

ps -u UID Show processes of a specific user

top Live view of running processes

pgrep pattern Find processes matching a pattern


pgrep -l pattern List PID and process name

kill PID Send SIGTERM (default) to a process

kill -SIGNAL PID Send specific signal

pkill process_name Kill processes by name

pkill -9 process_name Force kill process

Job Control

Command Explanation

sleep 500 & Run process in background

jobs List background jobs

fg %job_number Bring job to foreground

bg %job_number Resume job in background

kill -STOP %job_number Stop (pause) background job

kill %job_number Kill background job

Standard Input, Output, and Error

Command Explanation

command > file Redirect output to file (overwrite)

command >> file Redirect output to file (append)

command < file Use file as input

2> file Redirect standard error to file

command 2> errs > results Redirect error to errs and output to results

Pipelines and Redirection


Command Explanation

`command1 command2`

`ls -lR / more`

`ls -lR / tee file

Word Count and Text Processing

Command Explanation

wc [options] filename Word count utility

wc -c filename Character count

wc -l filename Line count

wc -w filename Word count

diff file1 file2 Compare two files

grep [options] pattern files Search for patterns

grep -i pattern Case insensitive search

grep -l pattern files List matching files

grep -n pattern files Show matching lines with line number

grep -v pattern files Invert match (show non-matching lines)

grep -c pattern files Count matches

grep -w pattern files Match whole word only

tr [options] string1 string2 Translate characters

`echo "Hello" tr 'A-Z' 'a-z'`

cut -f3 -d: /etc/passwd Cut field 3 from /etc/passwd


(colon-separated)

cut -c1-5 filename Cut characters 1 to 5


sort [options] file Sort file

sort -t: -k1 /etc/passwd Sort by first field using ":" separator

sort -t: -k3 /etc/passwd Sort by third field

sort -t: -n -k3 -o passwd_sorted Sort numerically by 3rd field and output to
/etc/passwd passwd_sorted

Day5
Topics Covered:

●​ Inodes & Links


●​ Package Management (RPM & YUM)
●​ Search Commands
●​ Archiving & Compression

COLLECTED COMMANDS & EXPLANATIONS

File System & Inodes

Command Explanation

ls -i fname Show inode number of a file

ls -id / Show inode number of a directory

cp f1 f2 Creates a new inode for the copied file

mv f1 f2 Keeps the same inode if in same filesystem

ln -s file linkname Create symbolic (soft) link

ln file linkname Create hard link (same inode)

Disk Usage
Command Explanation

df -h Show free space on mounted filesystems (human readable)

du -sh [dir] Show space used by a directory

RPM Package Management

Command Explanation

rpm -i file.rpm Install RPM package

rpm -e package Remove package

rpm -U file.rpm Upgrade (remove old, install new)

rpm -F file.rpm Freshen (update if installed)

`rpm -qa grep package`

rpm -qa --last List packages by install time

rpm --import key Import GPG key for package verification

YUM Package Manager

Command Explanation

yum search keyword Search for packages

yum list package Show versions available and installed

yum list installed List installed packages

yum list available List packages in repo

yum grouplist "string" Show groups matching string

yum install package Install package and dependencies

yum localinstall Install local RPM file


/path/file.rpm
yum remove package Uninstall a package

yum upgrade package Upgrade and remove old version

yum update package Update but keep old

yum provides file Find which package owns a file

yum repolist all Show all repos

yum clean all Clear YUM cache

File Search

Command Explanation

locate filename Fast search using database (needs updatedb)

updatedb Update locate database

find path -name Find files by name (live search)


"filename"

find path -size +10 Files larger than 10 blocks

find path -atime -7 Accessed within last 7 days

find path -mtime +5 Modified more than 5 days ago

find path -user user Owned by user

find path -type f Find regular files

find path -perm 644 Find files with specific permissions

Archiving & Compression

🔸 tar – Archive tool


Command Explanation

tar cvf archive.tar files Create archive


tar tf archive.tar View contents

tar xvf archive.tar Extract files

🔸 compress, uncompress, zcat


Command Explanation

compress -v file Compress file → .Z

uncompress -v file.Z Decompress .Z file

zcat file.Z View compressed file content

🔸 gzip, gunzip, gzcat


Command Explanation

gzip file Compress → .gz

gunzip file.gz Decompress .gz file

gzcat file.gz View .gz file content

🔸 bzip2, bunzip2, bzcat


Command Explanation

bzip2 file Compress → .bz2

bunzip2 file.bz2 Decompress .bz2 file

bzcat file.bz2 View .bz2 file content

You might also like