Linux Assignment
Table of contents
- 1] Tomcat install
- 2] Change the default Tomcat port to 9050
- 3] Create a new user and configure the necessary settings for secure login via Putty or other remote access tools
- 4] Configure Gmail on your Linux machine using Postfix/ Sendmail to enable sending emails from your Gmail Account through the command line
- 5] Establish passwordless connection between two linux servers
- 6] Create a new user account on your Linux machine and grant them sudo privileges
- 7] Use the 'scp' command to securely copy files and directories between Linux machines without password
- 8] Command that searches for files in the current and subsequent directories with a ".c" extension and the occurrence of the string "linux" within them.
- 9] How can you list the contents of a tar.gz file and extract a particular file
- 10] How can you compress a directory or file into a tar archive on Linux
- 11] Write a command to synchronize files and directories between 2 local folders
- 12] Write a command to synchronise a folder on local server and a folder on remote server
- 13] What is load average and swap memory in Linux
- 14] What are the important system directories in linux what they used for
- 15] What are the package installers for Redhat, Ubuntu, Debian, CentOS, Alpine
- 16] Connect to your Linux server using an FTP/SFTP client [Ex: winscpl client and copy a file from Windows to Linux.
1] Tomcat install
yum install java
wget https://downloads.apache.org/tomcat/tomcat-10/v10.1.16/bin/apache-tomcat-10.1.16.tar.gz.asc
tar xvzf <fname>
Go to /bin & then run the startup.sh shell script
./startup.sh
Open the browser & see the application
<ip_address>:<port_no>
2] Change the default Tomcat port to 9050
go to conf folder --> cd conf
in that open server file --> vi server
change d port to 9050
Now you can access through that port 9050
3] Create a new user and configure the necessary settings for secure login via Putty or other remote access tools
Create a user
sudo useradd
Create a .ssh folder
mkdir .ssh
set the permission to 700 --> chmod 700 .ssh
Create an authorised_keys file in it --> cd .ssh && touch authorised_keys
set the permission to 400 --> chmod 400 authorised_keys
copy and paste the public key to the new user
now login to the new user with putty using the private key
4] Configure Gmail on your Linux machine using Postfix/ Sendmail to enable sending emails from your Gmail Account through the command line
sudo yum install postfix s-nail cyrus-sasl cyrus-sasl-plain
Create a folder under /etc/postfix
cd /etc/postfix/sasl
Create a file sasl_passwd
Create an App Password from Gmail Account
Add this line into that file
[smtp.gmail.com]:587 <gmail>:<password>
- Make some changes in /etc/postfix/main.tf file
# Location of sasl_passwd we saved smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
# Enables SASL authentication for postfix
smtp_sasl_auth_enable = yes
smtp_tls_security_level = encrypt
# Disallow methods that allow anonymous authentication smtp_sasl_security_options = noanonymous
Start the postfix service
systemctl start postfix.service systemctl status postfix.service
Now you can send the mail using the below command
echo "<body of mail>" | mail -s "<subject>" <gmail>
5] Establish passwordless connection between two linux servers
we should have the respective private key in our server
then use the ssh command to connect to the other server you want to connect ssh -i <private_key> <user_name>@<public_ip>
6] Create a new user account on your Linux machine and grant them sudo privileges
Create a user --> sudo useradd
go to /etc/sudoers file --> sudo visudo /etc/sudoers
ALL= (ALL) nopassword: ALL add that line in the end of the file, by add it the user will get sudo privilages
7] Use the 'scp' command to securely copy files and directories between Linux machines without password
ssk-keygen -t rsa
To establish a passwordless connection, Generate a key pair by using ssh-keygen command. Copy the public key that was generated to the authorized keys file under .ssh folder on the server that you want to connect without the need to provide identity file
scp <file/dir name> @: now the above command is used to copy the files
8] Command that searches for files in the current and subsequent directories with a ".c" extension and the occurrence of the string "linux" within them.
find -type f maxdepth 1 -name "*.c" | grep -lR "linux"
9] How can you list the contents of a tar.gz file and extract a particular file
List Contents:
tar -ztvf <file>e.tar.gz
Extract a Particular File:
tar -xzf <file>.tar.gz <path>
10] How can you compress a directory or file into a tar archive on Linux
tar -cvzf <name>tar.gz
11] Write a command to synchronize files and directories between 2 local folders
rsync -options source_directory/ destination_directory/
12] Write a command to synchronise a folder on local server and a folder on remote server
rsync -av --delete -e ssh local_folder/ <user_name>@<ip_address>:<path>
13] What is load average and swap memory in Linux
Linux load average is a metric that shows the number of tasks currently executed by the CPU and tasks waiting in the queue
In Linux, swap memory is a space on a disk that is used when the amount of physical RAM (Random Access Memory) is full. When the system needs more memory resources and the RAM is fully occupied, it swaps out less used pages from the RAM to the swap space.
14] What are the important system directories in linux what they used for
/root --> root users home dir
/home --> uses home dir
/etc --> config files
/bin --> user binary files
/sbin --> system binary files
/var --> variable file
/opt --> thirdpart file
/dev --> device file
/usr --> user appliction
/mnt --> mount point
/sys --> virtual file system
/tmp --> temporary file
/lib --> system library
/proc --> process info
/media --> removable devices
/lost-found --> recover broken files
/run --> temporary file system
/boot --> boot loader files
/srv --> service data directory
15] What are the package installers for Redhat, Ubuntu, Debian, CentOS, Alpine
Redhat-rpm, yum
Ubuntu-apt
Debian-dpkg, apt
CentOS-yum,dnf
Alpine-apk
16] Connect to your Linux server using an FTP/SFTP client [Ex: winscpl client and copy a file from Windows to Linux.
-Open winscp
-Enter host name
-go to advanced, SSH - authorisation
-browse the private key file & click on OK