Every beginning is difficult. So that the entry into the world of the Linux commands allies could seem as difficult for you.

That’s why in this article we are going to tell you about ten most important Linux commands or command allies for beginners and newcomers. So that you do not stumble upon your first steps with Linux.

Almost every one of the commands presented here has many options and extensions. We only provide a basic overview and do not provide all the options for each command.

Note: Almost each and every commands presented here has many options and extensions. We only provide a basic overview and do not provide all the options for each command.

Preparations: Open a terminal window

Open a terminal window (also called a command line window or shell or console) on your Linux PC. On Ubuntu with Unity interface, enter “xterm” in the dashboard (which you can open with a mouse click on the Ubuntu icon in the upper left corner) and then start Xterm with a simple mouse click.

Alternatively, press CTRL + ALT + T (for other Linux distributions or desktop surfaces, use the appropriate keyboard shortcuts or menu items). By default relatively small Xterm window, you can raise at any time with the mouse pointer larger.

After opening you see the white cursor behind the command prompt (this defaults to your user name before @ and from the computer name after @. You can change the composition of the command prompt in the configuration file of your Linux system). At the end of this prompt, enter the Linux commands.

Tip: Use the CTRL + C key combination to cancel an output in the terminal window. This helps, for example, when a (faulty) command continuously delivers only garbage.

1. df : Display file system and storage space

The df command displays the file system including memory usage. For example, you can see at a glance how many hard drives are in your Linux PC and how much space is left on them. You can also see how each drive is mounted in the directory hierarchy.

To increase the readability of the output, you should always type “df” with the parameter “-h”, so “df -h”: Then the memory is displayed in Mbyte or Gbyte and not in Bytes. In turn, using “df -T”, the command names the file system for each partition and volume.

If you enter df together with the name of a directory, you will only see the data of the partition in which the directory is located.

2. Passwd: Change password

Even a secure password should be changed from time to time. And in particular, change a password preset by the manufacturer into a separate password.

So enter “passwd”. Linux then prompts you to enter your previous password (referred to in our example as the Unix password). The entry is invisible.

 Then you will be prompted to enter a new password. Repeat this again – both inputs are also invisible. And you already have your new password (please do not write it down on a post-it and stick it to the screen).

Attention: Linux is case-sensitive. Numbers and bindings and underscores are allowed, but commas or semicolons are not.

By the way: Linux stores the passwords encrypted in the file / etc / shadow.

With normal user rights you can only change your password with passwd. With root rights you can also change the passwords of all other users: “passwd username” is the command.

However, the old password no longer has to be specified here. With “passwd – l” (l stands for lock), Root can disable an account. The reactivation is done with “passwd -u” (u stands for unlock).

3. pwd: Where am I?

You have lost your orientation and no longer know which directory you are in. The bash command “pwd” helps and displays your current directory.

4. Whoami – who am I – and who

You are not sure what your username is under which you are logged in ?: “whoami” returns the answer (alternatively, you can also enter “who -m”.).

It makes sense, especially if you are often between different users or root switch back and forth and the username does not appear in the command prompt.

Whoami should not confuse you with the equally useful “who” – this will provide all currently logged in to your Linux system users.

After entering who you see, which user has logged in on which device on which day and at what time. With “who -a” you enforce a detailed output, for example with specification of the login time. An alternative to who is the id command.

Extra tip: With the command “last” you can see who was last logged in.

5. cp: copy and rename

With “cp” you copy files and entire directories in one go. An example of copying a single file to another directory: “cp name_of_file_destination_directory”.

If you specify a non-existent name instead of the target directory, the file is renamed.

With “cp -r source directory target directory” you copy a complete directory including the hidden files and the subdirectories.

6. ls: show directory

“Ls” lets you view all files and directories in the directory you are currently in. In our example (an Ubuntu system), directories are highlighted in blue, files in white. In each directory displayed you can switch with the command “cd” (see below). Hidden files and directories are marked with a prefix “.”.

For more detailed information about existing files and directories, enter “ls -al”. Then, for each file and directory, Linux will give you the file type (for example, “-” for files, “d” for directory), access rights, the number of hard links (which reference the file), the owner of a file, and to the group membership, to the file size (in bytes) and to the last modification date with time and finally the file or directory name.

In addition, the option “a” (for “all”) also ensures that system directories are displayed. The “l” (for long) provides the detailed, long output with each file and directory in its own line.

7. rm: delete files

First of all, you only delete files with “rm”. rm *. ~ deletes all backup files in the current directory.

Directories are only deleted with “rm” if you put the option “-r” behind them. The “r” stands for “recursive”: all directories and files are then deleted downwards from the user’s input location. And directories even if they still contain files or other directories and are therefore not empty.

This deletion is done on some systems with consultation, on others, but also without further consultation, so you can thus easily accidentally transport important files and directories into nirvana.

Attention: With the command “rm -r f ” you sweep all files and directories downwards from your location from the hard disk explicitly without the Linux system asking again. The “f” stands for “force”: It also deletes read-only files without asking for further information.

If you enter this command at the top level, ie with root alias “/”, you delete your entire Linux system, provided you are logged in as root. But even if you enter this command as a normal user, at least destroy all the files and directories that belong to you.

If you want to delete files with special characters in their file names, you must set the special characters between simple apostrophes, for example: rm ‘#’ * deletes all files in the directory that begin with #.

8. Clear: clean up the input window

You have lost track of countless entries and just want to have the input window nice and empty again: Type in “clear”. Alternative: CTRL + L.

9. Cat: Quickly display or create a text file

Do you want to quickly display the contents of a text file? Then type in “cat filename”. The terminal window then displays the contents of the text file.

For text formats that contain elaborate formatting marks and control characters, however, the output can be confusing. For a first overview, the output of cat but quite sufficient and simple txt files can thus even properly display.

10. cd: Change directory

With “cd ..” change to the next higher directory. If you get an overview of the existing directories with “ls”, then you can go to any directory with cd DIRECTORY NAME /.

You must pay attention to the exact spelling of the directory name. However, the tab key makes typing easier: Just type in the first or the first letter of the desired directory name and then press the TAB key to have Linux complete the name.

The command cd without parameters lets you switch to your home directory.

Important: You can also enter absolute paths in addition to relative paths (which you enter in the directory hierarchy depending on your current “location”): These are always specified completely beginning from the root directory, for example: cd/home/username/Documents.



LEAVE A REPLY

Please enter your comment!
Please enter your name here