The Top Ten Linux Commands for Beginners

You have installed Linux for the first time and/or have just switched from Windows to Linux? And want to deal with the infamous Linux commands? Then we have the right guide for you: The ten most important Linux commands for beginners and translators.

All beginnings are difficult. But this will of entry into the world of Linux commands alias shell commands alias console commands not too difficult, we have the ten most important Linux commands or command families for beginners and experienced users together. So that you do not get stuck in your first steps with Linux.

Important: There are many options and extensions for almost every command listed here. We only provide a basic overview and do not provide all the options for each command.

Preparations: Open a terminal window

On your Linux PC, open a terminal window (also called command-line windows or shell or console). In Ubuntu with Unity-Interface, you enter “xterm” in the dashboard (which you open with a mouse click on the Ubuntu-icon in the upper left) and 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). The standard relatively small Xterm window can be enlarged at any time with the mouse pointer

After opening, you will see the white cursor behind the input prompt (this consists of your username before the @ and the computer name after the @.) You can change the composition of the input request in the configuration file of your Linux system. Enter the Linux commands behind this prompt.

Tip: Use the key combination CTRL + C to cancel an output in the terminal window. This helps, for example, if an (erroneous) command only supplies garbage. In our example, we have an image file with cat (cat command with the filename, you can display the contents of plain text files, cat is only suitable for short files) display, which resulted in a very informative strong result.

1. Clear: clean up the input window

You have lost the overview after countless inputs and just want to have the input window simply blank again: Tap “clear”. Alternative: CTRL + L.

2. Whoami – who am I – and Who

You are not sure what your username is, where you are logged in: “whoami” provides the answer (alternatively, you can also type “who -m”.) Whoami makes sense when you are often between different users or root And the username does not appear in the prompt.

Whoami can not be confused with the also useful “who” – this provides all users currently logged on to your Linux system. After entering by who you can see which users on which device on which day and at what time is logged. With “who -a” you force a detailed output, for example with the login time. An alternative to who is the id command.

Extra tip: Use the command “last” let view who all was last registered.

3. pwd: Where am I?

You have lost your bearings and do not know which directory you are in. The bash “pwd” command will help and display your current directory.

4. df : Display file system and memory

The “df” command displays the file system including the memory allocation. So you can see at a glance how many hard disks are available on your Linux PC and how much space is still available. You will also see how each drive is mounted in the directory hierarchy. To increase the readability of the output, you should always type “-f” with the “-h” parameter, ie “df -h”: the memory location is displayed in Mbyte or Gbyte and not in bytes. With “df -T”, the command names the file system for each partition and volume.

Enter df together with the name of a directory, then you will only see the data of the partition where the directory resides.
5. Passwd: Change password

Even a password, which is still so secure, should be changed from time to time. And, in particular, change a password preset by the manufacturer into a separate password. Please enter “passwd”. Linux then prompts you to enter your previous password (in our example, a Unix password). The input is invisible. Then you are prompted to enter a new password. Repeat again – both inputs are also made invisible. And your new password (please do not write it down on a post-it and stick it to the screen).

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

By the way, the passwords saves Linux encrypted in the / etc / shadow file.

With normal user rights, you can only change your own password with passwd. With root privileges you can also change the passwords of all other users: “passwd username” is the command. However, the old password does not have to be specified. With “passwd -l” (l stands for lock), root can deactivate an account. The reactivation is done with “passwd -u” (u stands for unlock).

6. ls: Show Directory

With “ls”, you can view all files and directories in the directory where you are currently located. In our example (an Ubuntu system) directories are marked blue, files in white color. You can change the directory with the “cd” command in any directory displayed (see below). Hidden files and directories are marked with a prefix “.”.

If you want to know more about the existing files and directories, type “ls -al”. Then, Linux provides you with the file type (for example, “-” for files, “d” for directory) for each file and directory, access rights information, the number of hardlinks (which point to the file), the owner of a file, and To the file size (in bytes) and to the last modification date with time, and finally the file or directory name. 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 on its own line.

7. cd: Change directory

Press “cd ..” to go to the next directory. If you got an overview of the existing directories with “ls”, you can change to DIRECTORYNAME / cd in any directory. You must pay attention to the exact spelling of the directory name. However, the tab key makes the entry easier: Type only the first letter (s) of the desired directory name, and then press the TAB key to make Linux complete the name.

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

Important: In addition to relative paths (which you enter in the directory hierarchy depending on your current “location”), you can also enter absolute paths: Always start from the root directory, for example: cd / home / Username / Documents.

8. cp: Copy and rename

Use “cp” to copy files and entire directories in one go. An example of copying a single file to another directory is “cp filename_file”. If you specify a non-existing name instead of the target directory, the file is renamed.

Use “cp -r source directory target directory” to copy a complete directory, including the hidden files and subdirectories.

9. rm: Delete files

With “rm”, delete only files. Rm *. ~ Deletes all backup files in the current directory.
Directories are deleted with “rm” only if you set the “-r” option behind them. The “r” stands for “recursive”: all directories and files are then deleted downwards from the input location of the user. And even directories, even if they still contain files or other directories and thus are not empty.

This deletion is carried out on some systems with consultation, but on others without further inquiry, so you can easily inadvertently transfer important files and directories into Nirvana.

Warning: The command “rm -r f ” sweep all files and directories down from your location from the hard drive and indeed explicitly without the Linux system back asking again. The “f” stands for “force”: Also read-only files are deleted without a query.

If you enter this command at the top level, that is, at root alias “/”, delete your entire Linux system if you are logged on as root. But even if you type this command as a normal user, you destroy at least all the files and directories you own.

If you want to delete files whose filenames contain special characters, you must set the special characters between simple apostrophes, for example: rm ‘#’ * deletes all files in the directory beginning with #.
10. Cat: Quickly display or create a text file

Want to quickly view the contents of a text file? Then type “cat filename”. The terminal window then displays the contents of the text file. For text formats that contain complex formatting characters and control characters, however, the output is sometimes confusing. For an initial overview, the output of cat can be quite sufficient and simple txt files can be displayed even with it perfectly.

To create a short note in plain text format, simply type the default input from the keyboard, not the screen, but redirect it to a file: “cat> newfile”. Whereupon you replace new file with the desired filename. Once you have entered this command and pressed RETURN, the terminal will wait for your text. Enter it as you like, change the line by RETURN. When you are finished typing, type CTRL + D. This completes the input, the creation of the text file is terminated. Now type ls to check. You will find the new first text file in the directory. Use cat file name to display its contents.

You can also use cat to combine several text files. The three text files from our screenshot, namely new_notices, notes, and notes, are combined with this command into a single file: cat new_notices> notes> endnotices.

Leave a Reply

Your email address will not be published. Required fields are marked *