Top Linux Commands For Hosting – Shell Access Command

Linux is an open operating-system. Almost 60% of the website’s backend is operated by Linux os. Either you are a web developer, or hosting provider. You must have knowledge regarding Linux top Commands. To understand basics, continue reading

Linux OS operates through different working commands. Any Individual should know its top basic commands in case of troubleshooting its web apps.

In this blog post, we will be covering top Linux commands for hosting. To help a Sysadmin to troubleshoot whenever an error occurs. The lists of some very basic Linux commands may help you out.

Top Linux Commands for Hosting- for Sysadmins

Many hosting admins, so-called sysadmins, do not know much about Linux OS. But, as a sysadmin, if you are looking for top Linux commands that can help you in solving fundamental problems. Let’s be us.

We have mentioned-below some basics but necessary commands of Linux that are worth knowing. After understanding the following top 10 commands of Linux, you will become able to handle your hosting os system. That is based on Linux.Also You will learn fundamental commands that will help you to navigate through your Linux based OS system. To help you become able to make little changes by yourself. However, the more you use Linux commands, the more you will understand it better.

useradd – Linux command to add users

useradd
sudo useradd test_user
cat /etc/passwd | grep test_user
test_user:x:1002:1002::/hom/test_user:/bin/sh

To add another user to your Linux OS. Use this Command. Multi-users can use Linux OS at the same time. However, Admin has to create a new profile and password for the guest user.

The Command Useradd would be helpful if you are facing trouble in your web server app and could not find the right solution. To hire an expert to solve the error out, you may need to give him guest mode access.

Creating a new user profile with this Command is not rocket science. Just Use Command ‘Useradd Name’ And Enter a New password using this command ‘passwd 12234564’.

The thing to note here is that the passwd command always follows the Useradd Command.

To remove the New added User, use this Command Userdel. Doing this will force the user to logout.

History Command – Linux command to check the history of commands.

History Command
history

Operating VPS or Hosting using Linux, you may think about how many commands you have used. To see the history here is the Command. “History

The history command is not only useful for checking the history of your previously added commands but also it allows you to return those commands by adding numbers to that. For instance, after checking the lists, you can enter the number that will be there.

Each Command will be in the number of lists.

To access any of them, use this command “history !3” It will take you there in a hassle-free way.

PWD command – Linux command to check the current working directory

PWD command
pwd

Sometimes it becomes frustrating to work on Linux OS. Many sysadmins often use the PWD command to check the current directory name. To understand in which directory they are.

PWD command is pretty essential to understand Linux better.

Web Server admins use it whenever they forget the path in which they are surfing. For instance, the PWD command will prompt up the name of the directory to see if this is the right folder. in case you are finding your file somewhere. The Command will make it easy to get the work done.

Cd Command – Linux command to change directory

linux commands
cd /home

Use the cd command if you want to jump to a new directory. By means that it makes it easy to navigate through all of your directories.

In a Linux operating system, we create many folders; each folder consists of new files. For example, there are three folders. Each has its specific name. If you want to jump to any of the folders, simply write the title, followed by the CD command.

This is one of the TOP Linux commands that helps sysadmins to navigate all of the folders easily. Please write the name, and it magically lets you enter the folder instantly. Example “cd mp4  Files”

ls Command – Linux command to list folders and file in current directory

linux commands
ls -h

To list all files in a directory, use the ls command. It will automatically create a list of all the files that are stored in a folder.

ls command is meaningful, no matter for what purposes you are using the Linux OS. Ironically, the command helps sysadmin to look at all the files of a folder.

For example, If you want to see the audio files. Use the command like this “ls /home/username/audio” All the audio files will appear in the list.

rm command – Linux command to remove folder or file

rm command
rm -Iv test*
#select y on prompt

Linux OS users frequently use the rm command. The command helps to delete the files in a directory along with all the files.

However, in any case, you only want to delete the directory, not the files it contains. use the rmdir command

Before using practically this command, double-check the files you will delete because it is a one time process.

mkdir command – Linux command to make directory

mkdir command
mkdir test

Mkdir command lets the users create a new directory. Sysadmin quite often uses this command when they are bound up with the directories, so for creating a new directory, the command helps them out.

For Instance; mkdir Videos. A new folder/ directory will be created.

Same for generating a sub-Directory, you can use this command with the folder’s name. mkdir Video/mp4. A subdirectory mp4 will be created.

cp Command – Linux command to copy file or folder

cp Command
cp test /home/user/Destop

This is another top useful command in Linux. The Cp command can copy the file from a directory to anywhere you want. Imagine if you want to duplicate a file and place it in any different directory. Simply, use the Cp command “filename. (extension name)”.

And the command for moving a file is CV; the rest of the process is the same as the CP command follows.

locate command – Linux command to search file or folder

Linux commands
locate -i *sample*.txt* 
#txt file that contains sample in file name

To locate a file in your Linux Hosting server, use locate Command. It will find any file for you in just a matter of seconds.

But there are some tips:

  • To find a file with a single word name like Apple, use locate command and write the same name. Locate Apple
  • To find a file with two or more than two words, use an asterisk (*), for example. The file name you want to find on your Linux system is Apple Phones. In this case, you should cover the space between words with (*). Just like this, locate command Apple*Phones.

wget command – Linux command to download a file from web location

Linux commands
wget https://.....

Last but not least, the command is handy for downloading a file from the Internet. Use the wget command and put the URL of that file you want to download.

Process Management Command

process is the program currently running on the server. Sometimes, system admins are required to stop or kill a program that is taking a lot of resource. Follow the steps to display all the processes running and then kill specific program.

  • To display all running processes, ‘top‘ keyword is used . It displays complete information about the program like the load on the central processor, RAM, disk space and network etc.
  • The ‘ps‘ utility displays the processes of the current user .
  • The ‘kill‘ command stops (kills) the running program. However, it is not recommended to use in production environment. Use only when you know what you are doing.
Process Management Command
use ps command to list out active process and kill command to close specific running process

Date Command for Shell

  • Date command displays the date, time and day of the week. If you enter it without parameters, then it displays the current date, time and day of the week.
  • To get help on how to run date command, you can run sudo date –help or sudo man date.
Date Command

Using SSH Command on Shell

SSH allows secure transfer of data over encrypted channel. It launces the application from remote server using secure connection. Following are three different ways to connect to SSH:

  • Connecting to the server: Using the login and password of a user with right access sudo ssh user_name @ IP_server. After entering the command and specifying the password, the secure connection is established.
  • Executing the command using port: sudo ssh user_name @ IP_server -p:22. Default port to connect to ssh is 22.
  • Accessing SSH with key and without password: If the user has private key, user can run following command to create SSH connection without providing the password. sudo ssh-copy-id user_name @ IP_server.

Working with File Access

The chmod command changes the permission of the files and directories. It allows to enable or disable the execution of the file. Admins can also restrict the read-write access by using certain commands.

  • ls -lh : View the permissions of files and directories in the current directory.
  • To add read-write permission on a directory – chmod 777 folder_name.
  • Remove permissions for a directory (read only) – chmod 400 folder_name.
  • Assigning a user to the folder ownerchow user_name folder_name.
  • Removing user rights to a folder – chow -R user_name folder_name.

User and System Information

Sometimes it becomes necessary to obtain the information about the users and the system. Use following commands.

  • whoami: information about the currently logged in user .
  • who: information about all users of the current operating system. The command also allows to find out the IP address of the current logged in users.
  • uname: information about the operating system .
  • hostname: is the network name of the machine.

Installing Packages using Shell commands

Tow major types of packages can be installed through Shell command.

Deb package handling

  1. Install or upgradedpkg -i package_name.deb
  2. Removal - dpkg -r package_name
  3. Show all packagesdpkg –l

APT package manager

  1. Installation and updateapt-get install package_name
  2. Getting updated package listsapt-get update
  3. Upgrading packages installed on Ubuntu – apt-get upgrade
  4. uninstallation of packageapt-get remove package_name
  5. Checking the integrity dependencies of packagesapt-get check

Managing DNS settings from Shell

The hostname command displays the computer name and the domain name server

hostname is a name assigned to the computer connected to a network that uniquely identifies it on the network and thus allows access to it without using its IP address.

Managing DNS

hostname -i displays the network IP address.

hostname -d displays the fully qualified domain name(FQDN) of the computer

sudo hostname new_hostname changes the hostname on Linux server.

Please note that changes made using the above command will only take effect until the next reboot. To change the host name permanently, you can run hostnamectl from systemd in system and services manager

Read: How to Set Cron Job on Linux Server – Cron Job Working & Scheduling