Linux commands for a DevOps
These are various linux commands that a DevOps should know:-
ls
This command is used to list down the contents in a particular directory.Its syntax is
ls <paramaeter>
mkdir
This command is used to make a directory/folder in your system.Its syntax is
mkdir <directory-name>
mv
This command is used to move a file from one place to another. Its syntax is
mv /path/to/filename <destination>
cp
This command is used to copy a file from one place to another. Its syntax is
cp /path/to/filename <destination>
cp -r
This command is used to recursively copy a file or directory from one place to another.
cp -r <file/directory-name> <destination>
cd
This command is used to change to a particular directory. Its syntax is
cd <directory-name>
cat
This commands is used to concatenates a given file.Its syntax is
cat <filename>
rm -r
This command is used to recursively remove a file or directory.
rm -r <file/directory-name>
touch
This command is used to create a particular file. Its syntax is
touch <file name>
echo
This file is used to write content to a particular file. Its syntax is
echo <your-text> > abc.txt
vim
It is an editor that don’t comes on default. You need to install it on your system be executing
sudo apt install vim –y
For editing a file using vim execute below command
vim <file-name>
For exiting from vim press : and then write wq which means write quit
nano
This is an editor that comes by default, If it’s to see s not installed somehow then execute below command to install it
sudo apt install nano -y
For editing a file in nano execute
nano <file-name>
For exiting from nano press ctrl+x then press y for yes
sudo
This command is used to provide the root privileges, where sudo means SUPER USER DO. Its syntax is
sudo <command>
COMMANDS | DESCRIPTION |
sudo useradd <username> |
Add a new user into system |
sudo passwd <username> |
Assign password to a user |
sudo userdel <username> |
Delete a user from system |
sudo groupadd <groupname> |
Adding a new group into server |
sudo groupdel <groupname> |
Delete a group from server |
sudo usermod -g <groupname> <username> |
Adding a user to a group |
chown
This command is used to change the owner or group of a particular file. Its syntax is
chown <owner-name> <filename>
history
This command is used to check the history of all the commands executed on the server. Its syntax is
history
date
This command is used to show the date on the server, to see the date on server simply execute
ssh-keygen
This command is used to generate the public/private key on the server. Its syntax is
ssh-keygen
df -h
This command is used to check the disk space on a server. Its syntax is
df –h
apt-get
This command is used to handle packages in linux. Its syntax is
sudo apt-get <options>
htop
This command is used to check the load average on the server. Its syntax is
htop
ifconfig
This command is used to view/configure network interfaces. Its syntax is
ifconfig <options> <interface>
wget
This command is used to download any package from internet to system. Its syntax is
wget <url-of-package>
tail
This command is used to display last part of a file. Its syntax is
tail -f <file/location>
-f stands for follow
grep
This command is used to search the file patterns. Its syntax is
grep <pattern-name>
list users
For listing the users in the server execute the below command
awk -F':' '{ print $1}' /etc/passwd
scp
SCP stands for secure copy, for copying a file from local to server execute below command
scp -i <path-to-pem-file> <path-for-file-to-be-copied> user@<server-ip>:<path/on/server/where/file/to/be/copied>
Copy a file from server to local system environment
scp -i /path/to/pem-file user@your-ip: path/to/file /your/local/directory/files/to/download