Notes and practices to prepare for various Linux certificates like LPI Linux Essentials, LPIC 101 and Redhat RHCSA exam
Network Protocols - mostly use ports to transfer data.
Common Network Ports (Connections for Clients)
-
Port 22 - SSH (Open SSH)
-
Port 23 - Telnet (telnetd)
-
Port 25 - SMTP (Sendmail)
-
Port 53 - DNS (Bind, named)
-
Port 67 - BOOTP (dnsmasq, dhcpd)
-
port 80 - HTTP (Apache)
-
Port 443 - HTTPS (Apache)
Software Development Models
-
Cathedral Model (Organized, people will see the code once it's released)
-
The Bazaar Model (less organized, and relies heavily on developers' contributions)
Each package contains of
- Dependency Information
- Version Information
- Architecture Information
- Binary packages are packages that have an executable from source
Two common package systems are usually used today.
- RPM (Redhat)
- Debian
Debian based package manager uses apt
RPM based package manager = yum
RPM BASED COMMANDS!! Yum is tied to repos as RPM is tied to packages
rpm -ihv
- install and shows the progress in verbose mode (i,h,v)nano-2.2.6-1.x86_64
- package_name-version-buildNumber.architecturerpm -qi nano
- displays the detail information about the packagerpm -e nano
- Remove rpm packageyum search apache2
- search package in the yum package manager (apache2 is httpd.x86_64)yum check-update package name
- Check for updatesyum deplist httpd.x86_64
- list dependecies
ls -p
--p
flag indicates they are folders.ls -R
- Displays the contents inside a directoryhalt
- Shuts down the Linux operating system when super user or root userreboot
- Shutdown & Rebootinit 0
- Just like Shutdown (halt)init 6
- Just like Rebootsu
- switch usertop
- lists all the application and processesnetstat
- shows the statuses of the network and much more detailsroute
- view a routing table and manipulate routing tablesifconfig
- net configurations, can also modify configuration settingsip addr
- shows ip addresses (only in newer version of Linux)uname
- turns information about Linux-s
- displays the Linux kernel's name-n
- displays the host name-r
- displays the Linux release number-v
- displays ther version number-m
- displays the hardware architecture-p
- displays the processor type-i
- displays the hardware platform-o
- displays the OS
ls ??.txt
- find two letters.txt filesls *.txt
- find all files that ends with .txtls [F]*.txt
- search for all txt files that starts with capitalF
ls f[igh][lae]e*.txt
- first letter is f, second character consist ofigh
, third character with [lae], fourth letter of e.
Obviously, don't use wildcards in the file name!
man -k network
- search anything related to network
bin
- consists of executable filesboot
- boot related filesdev
- various hardware filesetc
- text based configuration files and services runninglib
- code library for files in thebin/
mnt
- external drivesproc
- Does not exist in our file system, sudo file system that is dynamically created when accessed.
grep -in james ./txt2.txt
find . -type f
- can work with directories as well,-type d
find . -type f | grep file
- find and pipe out the current directory and grep a file that includesfile
cut -d" " -f3 file2.txt | cut -c2
- cut delimeter by space of the field 3 of file2.txt then pipe out and cut column 2wc -w file2.txt | cut -d" " -f1
- only display the counted word, and not the file name
tail /var/log/messages 1> logtemp.txt
- redirecting the output of/var/log/messages
to a new file calledlogtemp.txt
. Output is redirected by using>
cat wrong_file.txt 2> error.txt
- Redirect the stdError output to the error.txt. This copies the error message to the error.txt, whereas1>
redirects the correct stdInput to the new file.ps >> runningproccess.txt
- APPEND the outputps command
to therunningproccess.txt
file.- 1
>
will replace or create a file, whereas 2>>
will append it to the file.
- 1
To log the information, we typically do below command to separate the stdinput and stderror
-
mount 1> mountfile.txt 2> mounterror.txt
- Add correct output to mountfile, if error occurs, logs it to mounterrortxt -
sort < words.txt
- the less than sign,<
will input. In this case, the contents in the words.txt file will be inputted to the sort command
[asd]
- matches any in the bracket^music
- matches the beggining of a file that starts with this wordmusic$
- matches end of the file.
- any charactergrep ^.b abc.txt
- anything that begins withsomethingb
grep ^...$ abc.txt
- grep anything that starts and end with only 3 characters ...ls file*
- will return anything that starts with file. file1, file2, file3 blahblahgrep [ser] ./hostnames
- grep files that contains any of the[ser]
. Will return files with onlyer
orr
.grep [^ser] ./hostnames
- grep files that DOES NOT CONTAIN[ser]
. Different from outside of bracket^
for i in `seq15`
do
echo "The current number is $i"
done
exit 0