[ls] lists directory contents

       
What are the basic commands in Linux?

Because it lists files and directories, the list (ls) command is identical to the DOS DIR command. You may see all the unhidden files in your current directory, which is your home directory when you first log into a Linux system, by simply typing ($)'at a command line.

On a fresh system, the ls command won't show you anything in your home directory, so let's look at a directory with a lot of files and directories: A Linux system's configuration files are found at /etc (et-see).

Displays manual pages

Pages from the manual are displayed. Almost all Linux commands, as well as the manual pages, are provided. A manual page, also known as a command page, is a type of documentation that explains what a command does, how to run it, and what inputs it accepts.


The man command displays the manual page for a certain command. For reference, Linux has a lot of documentation available online. They are referred to as manual pages in the manual. For quick access to this documentation, type command> and a screen full of information will show in front of you. The manual's pages are simple to navigate.

Use the Enter key to advance one line at a time, the b key to go back, the space bar to advance a full-screen page, and the q key to exit the man command page.

Cat command

The CAT command is useful as a basic command because it accomplishes two key tasks: it concatenates (merges) files and prints the contents of a file on the screen (as the name indicates). The most common usage of this command is to print the contents of the files. If you wish to see a file's contents, use the following format:

$cat <filename>

Creating symbolic links (ln command)

A symbolic link (or symbolic link) is a special file type that points to another file or directory. To create a symbolic link to a specific file, use the ln command with the -s option, the filename as the first argument, and the name of the symbolic link as the second argument:

 ln -s source_file symbolic_link 

If only one file is specified as an argument, ln creates a link to that file in the current job with the same name than the file to which it refers.

Removing files and directories (rm command)

To remove files and directories, use the rm command. When executed without an argument, rm does not remove folders by default. The user is also not requested to keep removing the chosen files. Use the rm command with the filename as an argument to remove a file or symbolic link:

rm file.txt 

rm takes one or more filenames or directory as arguments.

changes directory

The cd command and the pwd command are quite similar. On a Linux system, changing directories is a regular task. As previously stated, the first time you log in, you will be added to your home directory.

On a Linux system, each user has their own home directory. Personal directories for regular user accounts may be found in the /home directory. /home/username> is the location of your home directory. Click /home to see all of the user's home directories.

cd /home ls 

Your system determines what you see here. You will only see your home directory if you are the sole user on a personal system. Hundreds of user accounts are possible in production systems. Entering a CD without parameters or directory paths is a simple way to return to your home directory, regardless of where you are on the system: cd

Moving and renaming files and directories (mv command)

The mv command (short from move) is used to rename and move files and directories from one location to another. For example, to move a file to a directory, run: 

mv file.txt /tmp 

To rename a file, you must specify the destination file name: 

mv file.txt file1.txt

The grep command searches

Find text in a file. The grep command searches through many files at a time to find a piece of text you are looking for.

grep PATTERN [FILE]

The above command will find all of the words in the files that matched the word ‘failed’.

 grep ‘failed’ transaction.log

su / sudo command 

On a Linux system, certain tasks require elevated privileges to run. As a result, you execute it as a system administrator, which is something that ordinary users cannot accomplish. Your command alters the shell to be used as a superuser, and it can still be the sudo superuser until you use the exit command: if you just need to execute anything as a superuser, use the sudo command.

This permits you to run the command with elevated privileges, and after it's finished, your usual rights and permissions will be restored. Shutdown Command, for example Shutdown The shutdown command shuts down the computer system in a secure manner.
  • sudo shutdown 2 - Shutting down and changing your computer after 2 minutes 
  • sudo shutdown —r 2 — turns off and restarts in 2 minutes 
  • Using Ctrl C or Shutdown —c helps stop shutdown.

The pwd command

Although it is similar to the pwd command, it has a different purpose. This command is used to update the user account's password. You can update your password, as well as the passwords of other users. Normal system users can only change their own passwords, but root can change all of the accounts' passwords. update the user's password using password [username].

passwd admin