As a Linux user, working with command line can be a powerful tool as opposed to working through the GUI system. If you know your way around the command line, you will find yourself working a lot more efficiently. Here are some of our most used Linux commands that will ensure better management of your and your clients’ servers.
1. Display Your Path (Directory Location)
#pwd
Here is a sample output using pwd:
2. Make New Directories
#mkdir
Here we are creating a new folder called “potato”, and by using ls, we are able to list and see the new directory:
3. Remove Directories and Files
#rm -r or #rm -rf
To remove a directory that contains files, use this command; however, if you do not want to be prompted (this can be time-consuming and a tad annoying), use rm –rf to enforce it.
4. Move Files to a Different Directory
If you need to move a certain file somewhere else, use mv. For example, the following will move text file “file1” to path1/folder2/:
#mv path1/folder1/text1 /path1/folder2/
5. Display Current Processes
#top
If you notice your server running a tad slow, use this command to see what is taking up your CPU, as in the example below:
6. Display Used and Available Storage
#df -h
To check the amount of space you have available, use this simple command. Not only does it show you your available storage, it also shows you the sizes of each folder and where it is located. See below:
7. Display Network Configurations
#ifconfig or #ifconfig -a
Using either of these commands will display what your IPs are for each ethernet. If you have several ethernet interfaces, try using the following so you can view them all:
#ifconfig –a | less
8. Display Logged In Users
#w or #who
Do you have multiple users and want to know who is logged in? By typing w, it will display their user, local IP address, what time they were logged in, and how long they have been idle for.
Using who is essentially the same except it only shows the date, IP address, and user.
9. Setting Up Permissions and Ownership
#chmod or #chown
If you are not too familiar with chmod restrictions, look at the table below for some guidance:
The sample command would be:
#chmod (chmod option) fileNameHere
To set ownership to a specific file or directory, use chown. An example of this would be:
#chown owner:group fileNameHere
10. Display Memory
#free -m
To see your memory usage, use free –m and if you are ever in need of a RAM upgrade, let the Canadian Web Hosting team know!
Sample output:
Are there any top Linux commands that we missed? Let us know in the comments below!
[…] Type in “nice top -d 2 -u nobody -c” user nobody is set for Apache. You can learn all the top Linux commands here. […]