Linux Concepts
Linux Commands
whoami - Current user name pwd - Current working dir cd - Change dir ls - List file or folder ls -lrt - List file or folder with details ls -a - List hidden files mkdir dirname - Create a new directory rmdir - Remove the diretory rm filename - Remove file rm -rf - Remove direcory forcefully cp file name /destination - Copy filename to /desination directory mv filename1 filename1 - Rename filename1 to filename2 mv source destination - Move the file source to destination mkdir -p - Create subdirectory touch filename - Create empty file cat filename - Display the content of file echo "hi" - Print the "hi" in the terminal man ls - Display the manual vi filename - Open file with editor apt install tree - Install tree package tree . - List subdirectry rm -f - Force remove history - Display the command history history > history.txt - Copy the history to notepad cat /etc/os-release - About os information uptime - Provide information system running apt update - Update package lists (Debian/Ubuntu) yum update - Update package lists (RHEL/CentOS)
sudo usermod -s /bin/sh username sudo usermod −aG docker ubuntu sudo usermod -m -d /home/newuser newuser sudo useradd arunjai cat /etc/passwd clear sudo passwd arunjai sudo useradd -s /sbin/nologin lalith cat /etc/passwd su arunjai su lalith su passwd lalith sudo passwd lalith su lalith sudo usermod -s /bin/sh lalith su lalith cat /etc/group groups ubuntu sudo usermod -aG docker ubuntu groups ubuntu groups docker getent group docker sudo usermod -aG docker arunjai getent group docker cd /home/ ls /home cd .. su arunjai sudo usermod -m -d /home/arunjai arunjai sudo usermod -d /home/arunjai arunjai sudo groupadd ramesh cat /etc/group scp localfile username@remotehost:/path/to/remote/directory/ sudo useradd arunjai - Adds a new user named arunjai. cat /etc/passwd - Displays the contents of the /etc/passwd file, which contains user account information. sudo passwd arunjai - Sets or changes the password for the user arunjai. sudo useradd -s /sbin/nologin lalith - Adds a new user named lalith with the shell set to /sbin/nologin, preventing lalith from logging in interactively. cat /etc/passwd - Displays the updated contents of the /etc/passwd file. su arunjai - Switches to the user arunjai. sudo passwd lalith - Sets or changes the password for the user lalith. sudo usermod -s /bin/sh lalith - Changes the shell for the user lalith to /bin/sh, allowing them to log in interactively. cat /etc/group - Displays the contents of the /etc/group file, which contains group account information. sudo usermod -aG docker ubuntu - Adds the user ubuntu to the docker group, allowing them to run Docker commands without sudo. groups ubuntu - Displays the groups the user ubuntu belongs to. getent group docker - Retrieves and displays the docker group entry from the group database. sudo usermod -aG docker arunjai - Adds the user arunjai to the docker group. getent group docker - Retrieves and displays the updated docker group entry. sudo usermod -m -d /home/arunjai arunjai - Moves the home directory of the user arunjai to /home/arunjai. sudo usermod -d /home/arunjai arunjai - Sets the home directory of the user arunjai to /home/arunjai (the -m option moves the contents of the old home directory to the new one). sudo groupadd ramesh - Creates a new group named ramesh. cat /etc/group - Displays the updated contents of the /etc/group file. sudo init 6 - Reboots the system (init 6 is equivalent to a reboot). scp -i /path/to/your-key.pem /path/to/local/file username@remote_host:/path/to/remote/directory sudo apt update sudo apt install ufw sudo apt-get install nginx sudo yum install nginx sudo service nginx start sudo service nginx stop sudo service nginx restart sudo service nginx status sudo systemctl restart nginx sudo systemctl start nginx sudo systemctl stop nginx sudo systemctl status nginx sudo systemctl enable nginx - Enable nginx in System startup sudo ufw status sufo ufw allow ssh sudo ufw allow SSh sudo ufw allow SSH sudo ufw allow ssh sudo ufw allow 'Nginx Full' sudo ufw enable sudo ufw status ctrl l cd /var/www/html echo "helloworld" sudo touch index.html sudo echo "Helloworld" > index.html sudo vi index.html sudo rm index.html sudo kill -9 process_ID echo "" | sudo tee -a /var/www/html/index.html