0% found this document useful (0 votes)
11 views2 pages

Redhat Adminexported

The document outlines the history and structure of Linux, detailing its development from early operating systems to modern distributions like Red Hat and Ubuntu. It covers essential Linux commands, file system hierarchy, user management, package management, and process management. Additionally, it includes information on permissions, remote login, and text processing tools.
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)
11 views2 pages

Redhat Adminexported

The document outlines the history and structure of Linux, detailing its development from early operating systems to modern distributions like Red Hat and Ubuntu. It covers essential Linux commands, file system hierarchy, user management, package management, and process management. Additionally, it includes information on permissions, remote login, and text processing tools.
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/ 2

‎Redhat Admin 1

‎1965 - MIT & GE & Bell Labs ‎Multics OS

‎1968 - Bell Labs (AT&T) ‎Unics OS ‎Unix1, Unix2

‎ tudents took Unix + Some APPs and Made


S
‎1976 - Berkeley University ‎Bell Labs Made a License
‎BSD (Berkeley Software Distribution)

‎1983 - Richard Stallman ‎Retired from Bell Labs and Started his own Project ‎GNU (Open Source)

‎Linux History ‎1991 - Linus Torvalds ‎Made some enhancements to unix kernel

‎GNU + Linus's Kernel = GNU Linux

‎1995 - Windows Came with GUI ‎Xorg made Xprotocol (Linux GUI)

‎Redhat = Linus Kernel + Richard's GNU +Xprotocol + Apps ‎Made RHEL and Fedora

‎Debian Made the Same thing and Came up with Debian and Ubuntu

‎CentOS

‎Vmware or Virtual Box


‎Linux Installation
‎ISO

‎Root ‎User ID = 0

‎Linux Users ‎Service Users ‎0 < User ID < 1000

‎Standard Users ‎User ID >= 1000

‎/ ‎Contains all the file system

‎/root ‎Contains the root home directory ‎Desktop, Downloads,Documents.....

‎/home ‎Contains a Directory for each User ‎Ex: /home/mohamed/ Desktop, Downloads........

‎/bin ‎Contains the binary files of the Commands ‎Ex: the binary files of the ls, cd, mv commands

‎/sbin ‎Contains the binary files of the System Commands ‎Ex: the binary files of the useradd, userdel Commands

‎Browsing the File System ‎/etc ‎Contains Configuration Files

‎/tmp ‎Contains Temporary Files

‎/var ‎Contains variable size files ‎Ex: logs files

‎/dev ‎Contains Device files

‎/proc ‎Contains Currently Running Processes files

‎/boot ‎Contains boot loader(grub) and kernel

‎cd ‎Change Directory ‎Ex: cd /home/ali

‎pwd ‎Print Working Directory ‎Output: /home/khaled/Desktop

‎ls -a ‎List all files including hidden files

‎ls -l ‎Long listing (list files with some information)

‎ls ‎List all files in a directory ‎ls -r ‎Reverse List

‎ls -R ‎Recursive

‎ls -d ‎directory info

‎cp ‎Copy files from source to destination ‎Ex: cp file1 /home/ali/Desktop

‎mv ‎Move or Rename files ‎Ex: mv file1 /home/ahmed/Desktop ‎Ex: mv file1 file2

‎mkdir ‎Make a new directory ‎Ex: mkdir directory1

‎rm ‎delete files ‎Ex: rm file1

‎su ‎Switch User ‎used to change the current logged in user ‎Ex: su - root
‎ unning Commands and
R
‎Command <Options> <Arguments> ‎passwd ‎change user password ‎Ex: Passwd khaled
‎Getting Help
‎useradd ‎add a new user ‎Ex: useradd Mohamed

‎userdel ‎Delete a user ‎Ex: userdel Mohamed

‎head ‎display the first 10 lines of a text file ‎Ex: head file1.txt

‎tail ‎display the last 10 lines of a text file ‎Ex: tail file1.txt

‎wc ‎Word Count ‎Display the Number of lines, words and characters of a file ‎Ex: wc file1

‎cat

‎more

‎whatis

‎groupadd ‎Ex: groupadd sales

‎-G overwrite
‎usermod ‎Ex: usermod -G sales mohamed
‎-a append

‎Ex: gpasswd group1 -a mohamed

‎gpasswd ‎used for group administration ‎Ex: gpasswd group2 -M khaled,ahmed,mohamed

‎Ex: gpasswd group3 -d hassan

‎mount /dev/sdb1 /home/ahmed/Desktop/dir1


‎Mount , Unmount ‎Devices Located in /dev/sda1 or sdb1 .....
‎umount /home/ahmed/Desktop/dir1

‎ifconfig ‎Show Interface and IP Information

‎ifdown InterfaceName ‎Disable Interface

‎ifup InterfaceName ‎Enable Interface

‎Network ‎Interface Configuration File Can be Found /etc/sysconfig/network-scripts/ifcfg-interfaceName

‎hostname Server1 ‎Changes the host name to server1 ‎the result will be root@server1 ‎will be reset after reboot

‎edit /etc/hostname file ‎Changes the host name Permanently

‎hostnamectl set-hostname server5 ‎Changes the host name Permanently

‎Dns ‎Cache ‎LocalDns "/etc/hosts" ‎Resolver "/etc/resolv.conf"

‎Password ‎ssh User@IP

‎ enerate Public + Private Key in /home/yourUserName/.ssh


G
‎SSH ‎ssh-keygen -t rsa
‎you can Enter Passphrase to protect your Key

‎ opy Your /home/yourUserName/id_rsa.pub


C
‎Key Based ‎ssh-copy-id RemoteUser@IP
‎to remote Server in /home/remoteUserName/.ssh/authorized_keys
‎Remote Login
‎ssh -i /home/yourUserName/.ssh/id_rsa RemoteUser@IP ‎Login to Remote Server with your Private Key (without Password)

‎scp source destination:file ‎from our Machine to remote server


‎SCP
‎scp source:file destination ‎from remote server to our machine

‎Ex: add user to "wheel" group

‎Sudoers File ‎gives user administrator privileges (use sudo command) ‎Ex: nano /etc/sudoers

‎Ex: visudo

‎ls -l 1> outputfile 2> errorfile ‎">" overwrite ">>" append


‎Output Redirection
‎ls -l &> file1 ‎output and error in the same file

‎I/O Redirection , Piping , Tee ‎tr 'a-z' 'A-Z' < /etc/passwd ‎Input Redirection

‎ iping gets the output of a command and use it


P
‎Ex: head -5 /etc/passwd | tail -2 | tr 'a-z' 'A-Z'
‎as the input of the next command

t‎ ee stores the output to a file then execute the


‎Ex: head -5 /etc/passwd | tee f1 | tail -2 | tee f2 | tr 'a-z' 'A-Z' > f3
‎rest of the command

‎every file has an owner, group and other ‎each one has his own permission

‎Owner " u " , Group " g " , Other " o " , All " a "

‎ x: chmod u=rwx , go=r


E file1
‎Symbolic ‎Read " r " , Write " w " , Execute " x "
‎Ex: chmod u+x , g-w file1

‎Grant " + " , Deny " - " , Set " = "


‎we have to ways to change a permission

r‎ wx = 4+2+1 = 7
‎ x: if we want a file permission to be rwx rw- r--
E
‎Numeric ‎Read = 4 , Write = 2 , Execute = 1 ‎rw = 4+2+0 = 6
‎we will use the following comand: chmod 764 file2
‎r = 4+0+0 = 4

‎chgrp ‎used to change the group of a file ‎Ex: chgrp sales file1

‎Users , Groups , Permission ‎ x: chown


E owner:group file1
‎Ex: chown mohamed:sales file1
‎chown ‎used to change the owner of a file
‎Ex: chown :Marketing file1

‎ nables any user to run a file with the Owner


E
‎Set User ID (SUID)
‎Privileges

I‎nherit Group Ownership to all of the files


‎Special Permissions ‎Set Group ID (SGID)
‎created in that directory

‎Sticky Bit ‎Only the Owner of the File can delete it

‎Change the default Permission of a user ‎Ex: umask 027


‎umask
‎user umask is 002 by default , root umask is 022

‎Command Mode ‎Press " i " to Enter insert mode

‎Insert Mode ‎Press " ESC " to get back to Command mode

‎Vim ‎Exit ‎in Command mode use " :w " to write ‎" :wq " to write and quit ‎" :q! " to exit without saving

‎' / ' used to search

‎type 6 then press shift + g ‎Jump to Line Number 6


‎Commands
‎'dd' to Delete a line

‎'A' used to append ‎Jump to the end of a line and enter insert mode

‎yum ‎Centos 7 Package Manager

‎dnf ‎Centos 8 Package Manager

‎yum install nano ‎Checks the Repository and start installing nano ‎Repositories Could be Found at /etc/yum.repos.d

‎Package Management ‎yum repolist ‎View enabled repos

‎yum clean all ‎Remove the Repo data

‎yum remove PackageName ‎used to remove a package

‎yum search apache ‎search for a package ( result will be httpd )

‎Ex: service httpd [status, start, stop]


‎service ServiceName Action
‎Ex: chkconfig httpd on

‎Ex: systemctl start httpd


‎systemctl Action ServiceName
‎Ex: systemctl enable httpd
‎Service Management
‎netstat -ltpn ‎View Listening Ports

‎Managed by firewall-cmd

‎firewall service ‎firewall-cmd --list-all

‎firewall-cmd --add-service=http ‎we can add --permanent so we don’t lose the configuration after reloading firewall

‎cut ‎used to extract a column ‎Ex: cut -f 1,3 -d : /etc/passwd

‎Text Processing ‎grep "khaled" /etc/passwd

‎grep ‎used to extract rows matching a criteria ‎grep -A2 "khaled" /etc/passwd

‎grep -B2 "khaled" /etc/passwd

t‎ he fastest way to search for a file in linux but it’s using a pre-built database of
‎locate ‎paths to files on the system ‎Ex: locate file1
‎DataBase must be updated by admin using "updatedb" Command

‎Ex: find /home/khaled -name file1


‎Searching in Linux
‎Ex: find /home/khaled -iname file1 ‎ignore case sensitive

‎Ex: find /home/khaled -user khaled -group khaled


‎find ‎is used to search for a file with a criteria ‎find StartingDirectory Criteria
‎Ex: find /home/khaled -user khaled -o -user ali

‎Ex: find /var/log -size +1M

‎Ex: find -name "*".txt -delete

c‎ = Create an archive
‎t = list an archive
‎x = extract files from an archive
‎tar is an archiving tool in linux ‎tar cvf ArchiveName Files... ‎v = verbose
‎f = file name
‎z = use gzip compression
‎Archiving ‎j = use bzip2 compression

‎zip -r ArchiveName.zip /etc ‎unzip ArchiveName.zip to extract

‎ps ‎Display Active Process

‎ps -aux ‎display all processes and users

‎Kill ProcessID ‎Terminate a Process

‎kill -9 PID ‎Force Kill

‎Ex: pkill firefox


‎pkill ProcessName
‎Ex: pkill -u khaled

‎pgrep ‎Process grep ‎Ex: pgrep bash ‎display bash process id

‎Process Management ‎pidof bash ‎display the process id of bash

‎nice -n -15 sleep

‎renice -n -15 PID

‎sleep 10 & ‎run process in background

‎jobs ‎view background processes

‎fg % 1 ‎return process number 1 to foreground

‎ctrl + z ‎stop a process

‎bg % 2 ‎resume a process in background

‎ an be Found at
C
‎Global ‎/etc/bashrc
‎/etc/profile
‎Startup Files
‎ /.bashrc
~
‎User-Specific
‎~/.bash_profile

You might also like