This article gives insight into the basic commands of your Linux System. Many people think that, Linux commands are too heart to learn, but it’s not so hard. It’s simple as it is. To learn more about the various commands, it is usually possible to get additional information with the man program followed by the name of the command, for example, man ls. So, let me show you the all Basic Linux Commands via this article.
1. Listing Files and Directories
ls [option(s)] [file(s)]
If you run ls without any additional parameters, the program will list the contents of the current directory in short form.
- -l [detailed list]
- -a [displays hidden files]
2. Copying and Pasting
cp [option(s)] sourcefile targetfile
Copies source file to target file.
- -i [Waits for confirmation, if necessary, before an existing target file is overwritten]
- -r [Copies recursively (includes sub directories)]
3. Moving file and directories
mv [option(s)]source file target file
Copies source file to targetfile then deletes the original sourcefile. mv stands for move source file to target file. mv is also used for rename file or directory name.
4. Changing Directories
cd [options(s)] [directory]
Changes the current directory. cd without any parameters changes to the user’s home directory.
Switch to previous Directory or Location from Present Working Directory.
Your home directory is the directory you’re placed in, by default, when you open a new terminal session. It’s the directory that holds all your settings, your mail, your default documents and downloads folder, and many other personal items. It has a special representation: a tilde (“~”).
5. Showing Current Date and Time
This simple program displays the current system time. If run as root, it can also be used to change the system time. Details about the program are available in date.
6. Calculate Space Occupied by Directories
du [option(s)] [path]
This command, when executed without any parameters, shows the total disk space occupied by files and sub directories in the current directory.
7. Display Current Directory Path
Display the path name for the current directory.
8. Showing Processes
Display a snapshot of the currently running processes.
9. Creating New Directory
mkdir [options] Directory Name
To Create a new directory.
10. Removing Empty Directory
rmdir [options] Directory Name
To Delete/Remove empty directories.
11. Displaying Help Manual
man [command name]
Display the help information for the specified command.
--help [command name]
If you’re not sure how to use a specific command, run the command with the –help switches. You’ll see usage information and a list of options you can use with the command. For example, if you want to know how to use the ls command, type ls –help
12. Creating Empty Files
touch [file name]
To Create an empty file with the specified name.
13. Removing Files and Directories
rm [file name]
To Remove (delete) file(s) and/or directories.
rm -rf [non-empty folder name]
To Remove (delete) directories which is not empty.
14. Editing Files with Nano
To edit or write any text with the specified name.
15. Read Text Files
cat [file name]
To read all types of text files.
16. Display Logged in Users
Get the information on currently logged in users.
17. Display Current User
To know the current user who is in the shell.
18. Switching Users
sudo su [options] [user [arguments]]
Switch to another user account.
19. Changing Password
passwd [name [password]]
To change the password or allow (for the system administrator) to change any password.
20. Pinging a Network
ping [option(s)] host name|IP address
The ping command is the standard tool for testing the basic functionality of TCP/IP networks. It sends a small data packet to the destination host, requesting an immediate reply. If this works, ping displays a message to that effect, which indicates that the network link is basically functioning.
-c = [number Determines the total number of packages to send and ends after they have been dispatched. By default, there is no limitation set.]
By now, you should have a basic understanding of how to see the files and directories using commands in your Linux Operating System. You should also know some basic file manipulation commands that will allow you to view, copy, move, or delete files. Finally, you should be comfortable with some basic editing using the nano text editor.