Linux
Q: Describe below listed Commands?
- ls - list the files and directories in the current directory
ls
- cd - change the current directory
cd dir_name
- mkdir - create a new directory
mkdir rohan
- rmdir - remove a directory
rmdir rohan
- pwd - print the current working directory
pwd
- cp - copy files or directories
#We will copy a file called example.txt from the current directory to a directory called backup
cp example.txt backup/
- mv - move or rename files or directories
mv example.txt backup/
- rm - remove files or directories
rm example.txt
- touch - create a new empty file or update the timestamp of an existing file
touch shayan.txt
- cat - concatenate and display files
cat example.txt
- man - manual for a command
man ls
- htop - an interactive process viewer and system monitor
htop
- chmod - change the permissions of a file or directory
# The first digit represents the owner of the file/directory
# The second digit represents the group that the file/directory belongs to
# The third digit represents all other users
# 0 (no permission)
# 1 (execute only)
# 2 (write only)
# 3 (write and execute)
# 4 (read only)
# 5 (read and execute)
# 6 (read and write)
# 7 (read, write, and execute)
chmod 700 file.txt
chown - change the owner of a file or directory
chown new_owner example.txt
- tar - create or extract compressed archive files
# x: extract files from an archive
# t: list the contents of an archive
# r: append files to an existing archive
# z: use gzip compression
# j: use bzip2 compression
# cf: create file
#xf: extract file
tar cf archive.tar file1 file2 file3
- gzip - compress files
gzip file.txt
- gunzip - decompress compressed files
gunzip file.txt.gz
- ssh - connect to a remote server securely
ssh username@server_address
- scp - securely copy files between systems
scp myfile.txt user@remotehost:/home/user/
- ping - test network connectivity
ping google.com
- ifconfig - display or configure network interfaces
ifconfig
- netstat - display network connection information
netstat
- route - view or configure network routing tables
route [options] [add/delete/show]
- top - display system resource usage and processes
top
- ps - display information about running processes
ps aux
- kill - terminate a process
kill [PID]
- systemctl - control system services and settings
# Start the nginx service
systemctl start nginx
# Check the status of the nginx service
systemctl status nginx
# Stop the nginx service
systemctl stop nginx
- service - control system services
service apache2 start
- useradd - add a new user to the system
useradd harry
- passwd - change the password for a user
passwd harry
- userdel - delete a user from the system
userdel harry
- su - switch user to become another user
su john
- sudo - execute a command as another user or with elevated privileges
sudo
- uptime - display system uptime and load average
uptime
- df - display disk space usage
df
- du - display disk usage by file or directory
du
- mount - mount a file system
sudo mount /dev/sdb1 /mnt/usb
- umount - unmount a file system
sudo umount /mnt/usb
- date - display or set the system date and time
date
- whoami - display the current user name
whoami
- which - locate a program or command in the system path
ls
- finger - displays all the information about user
finger harry
- uname - display system information
uname
uname -a
- history - display a list of previously executed commands
history
- echo - display text or variables to the console
echo 'I need Tshirt from codeswear!'
- tee - redirect output to both a file and the console
$ ls | tee file.txt
- locate - locate any file on the system
locate file.txt
- sort - sort lines of text in a file or input
cat file.txt
banana
orange
apple
sort file.txt
apple
banana
orange
- uniq - remove duplicate lines from a file or input
cat file.txt
apple
orange
banana
apple
banana
uniq file.txt
apple
orange
banana
- head/tail - display the first/last few lines of a file or input
#display first 10 lines
head file.txt
#display last 10 lines
tail file.txt
========================Linux OS====================
Q: Write difference between Linux and Unix.
Q: What is the difference between BASH and DOS?
- In BASH, commands are case-sensitive. In DOS, commands are not case-sensitive.
- In this, / character are directory separator
- and \ acts as an escape character. In this, \ is a directory separator and / acts as a command argument delimiter.
- It can take input with its built-in “read”
- command. It cannot take input during run time and one can only pass “/argument” during execution from the command line.
Q: How to create private DNS in Linux
Ans:
1. Navigate to etc/host file and add hostname with IP address
2. vi etc/host
<IP address> <any hostname>
3. save and close the file (:wq)
Q: where all user will stored in Linux
Ans:
ls /home/ will show all users
ls -la /home/<user name> will show all files related to that user
user/bin/ -> contains all commands for any user
Q: How to create SSH keypair(public /private key) ?
Ans: ssh-keygen -t rsa
Copy the public file /root/.ssh/id_rsa.pub & paste in Client /root/.ssh/authorized_keys file
Q:How to install webserver on Linux
Ans:
Install httpd package on CentOS 7 or CentOS 6
[root@testvm ~]# yum install httpd -y
Start httpd service on CentOS 7.x
[root@testvm ~]# systemctl start httpd
Start httpd service on Boot on CentOS 7
[root@testvm ~]# systemctl enable httpd
Check httpd service Status on CentOS 7
[root@testvm ~]# systemctl status httpd
Go to document root of the web server
[root@testvm ~]# cd /var/www/html
Edit document root of the web server with your index file.
[root@testvm html]# vi index.html
Open Port 80 in Security Group on AWS Cloud Platform
Now Browse Your Public IP
Have Funnnnnn...!!!
Comments
Post a Comment