Linux basic commands:
du -sh * | sort -h -r | head -n 40 : list out first 40 files in the directory that are taking more space in the directory.
cd: change directory
Is-l listing the items in long listing format
pwd: print working directory
Is-I format: type :no of links:owner : group:size :month :day :time :name
cd/: go to/directory
whoami: tells us by which username we are logged in.
touch jerry: creates the file named jerry in present working directory.
cp jerry lex: copy the content of jerry file and paste it to lex file.
vi text1: creates the file text1 and open it in vi editor
mkdir superman: creates the directory called superman
mkdir abc def : creates 2 folder in one command.
touch filename wont work in /etc/ folder if logged in by normal account.
man cp: shows manual for cp command.
echo "india is my country"> file1 puts the text in file1.
rm filename: remove the filename
mv lex luther renames the file from lex to luther
mv luther /home/sadik: move luther to this location
rmdir dirt removes the directory named dir1. dd
rm-Rf dir1: will forcefully remove the subdirectories and its content as well.
chgrp root filename: will change the group of filename to root.
chown sadik:sadik filename: change the owner and group of filename to sadik.
inode: its a pointer or a number of a file on the harddisk
soft link: link will be removed if file is removed or renamed.
hard link: deleting, renaming or moving the original file will not affect the hard link.
ln: creates the hard link
ln -s: creates the soft link
cd /tmp: go to tmp directory
ln -s /home/sadik/hulk creates the soft link to the hulk file.
echo "I love my country" >> hulk appends this text to hulk file.
Is-1/root 2>errorfile: redirects the error to the errorfile.
telnet localhost 2> errorfile: redirects the error to the errorfile.
ls -ltr | more: list the items in the directory and shows the output one page at a time.
ls-1 | tail-1: this will list the last item inside the directory. man Is: give the description of the command and options used with the command.
ls --help gives the options used with the ls command,
whatis ls: gives the description of the command.
................................................................
Control services and daemons :
Services or applications when run in the background creates processes ,and when these processes continuously run in the background , they become daemons . most services run continuously in the background So we can call them as daemons .
Services are controlled by systemctl .
systemd is the parent process of most of the daemons .
command to control the services : systemctl .
systemctl --version : shows the version of systemctl
ps -ef | grep system : check if the systemd process is running or not .
systemctl --all : check all the running services .
systemctl status application.service : check the status of the service .
systemctl start application.service : start the service
systemctl stop application.service : stop the service
systemctl restart application.service : restart the service .
systemctl reload application.service : reload the configuration of the service
systemctl enable application.service : enable the service at boot time
systemctl disable application.service : disable the service at boot time
systemctl mask application.service : enable the service completely at boot or manually
systemctl umask application.service : disable the service completely at boot or manually
rpm -qa : list all the packages installed .
rpm -qa | wc -l : gives the count of the packages installed .
........................................................
configure and secure ssh :
steps to secure SSH:
1. configure the idle timeout interval
2.disable root login
3.disable empty passwords.
4.limit users ssh access .
5. change the port from 22 to other port .
...................................
Monitor and secure logs :
go to /var/log
and then check the content of
boot.log
chronyd
cron
maillog
secure
messages
httpd
......................................................
date : shows the date
timedatectl : shows the local time , universal time , time zone , shows ntp service is active or not .
timedatectl --help : give the options that can be used with this command .
timedatectl list-timezones : lists all the timezones available .
timedatectl set-timezone America/New_York : set the timezone to newyork timezone .
timedatectl set-time HH:MM:SS : sets the time .
timedatectl set-time '2024-03-23 12:14:11' : sets the date as well as time .
timedatectl set-ntp true : enable NTP synchronisation .
........................................
Chronyd : its a replacement for ntp .
purpose of chronyd is time synchronization :
package name : chronyd
configuration file : /etc/chronyd.conf
log file : /var/log/chrony
service : systemctl start/stop/restart chrony .
program name : chronyc
rpm -qa | grep chrony : checks if the chrony package is installed or not .
yum install chrony : installs the chrony package .
systemctl status ntpd : check the status of ntpd service .
................
compress and uncompress files:
tar: it takes the bunch of files together and put it in the container. tar does not compress as much as actual gzip command
gzip command: compresses the file.
gzip -d or gunzip: used to uncompress the files.
tar cvf file.tar /home/jaime: put everything you see in /home/jaime in the file.tar.
tar xvf file.tar: extract all the files inside file.tar.
gzip file.tar: compress file.tar. (file.tar will become file.tar.gz)
gzip -d file.tar.gz: uncompress file.tar.gz (file.tar.gz will become file.tar
...................................................
Accessing the linux File Systems:
command to find out which file is taking more space in the directory
#du -sh * | sort -hr | head -n30
Filesystem is the structured way where all the files and directories are stored.
Following are the ways or commands to access the linux File system:
Is
cd
pwd
df
du
fdisk
Absolute and relative path
~
..
cd :goes to previous directory.
fdisk-1: lists the disks and its information and lists the partitions created on the disks.
fdisk /dev/sdb: it will open fdisk program for sdb disk where you can create the partition. delete the partitions, expand the partition, list the details of the disk, change the partition type and much more.
cd ~ :go to home directory.
.............................................
Analyze the server and get support:
Anytime you have issues with the redhat server, you will have to go through commands such as top, free, df,du, etc. As the system administrator should also review the system logs in var/log directory and then reach out to redhat technical support for more help.
Redhat has made it easier for the system admin to use the web-based application named cockpit to manage and analyze the server.
To get the support from redhat, system administrator can run the utility "sos report" on Linux system as root which will collect the logs and configuration file and then transfer them over to redhat support server. Now with the cockpit application, the report can be generated at the web based portal.
.............................................,.......................
Comments
Post a Comment