Have you installed Linux for the first time and / or have you 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 those switching.
We present the ten most important Linux commands for Linux beginners.
© isak55 / Shutterstock.com
Every beginning is difficult. But with that the
Entry into the world of Linux commands
alias command line commands alias console commands are not too difficult, we have the ten most important
Linux commands or command families for beginners and those switching
compiled. So that you don’t stumble upon your first steps with Linux.
Important: There are numerous options and extensions for almost every of the commands presented here. We only offer a basic overview and do not present all options for each command.
Preparations: Open a terminal window
Open a terminal window on your Linux PC (also called a command line window or shell or console). In Ubuntu with a Unity interface, enter “xterm” in the dashboard (which you open by clicking on the Ubuntu icon in the top left) and then start Xterm with a simple mouse click. Alternatively, press the key combination CTRL + ALT + T (for other Linux distributions or desktop interfaces, use the corresponding key combinations or menu items). The standard relatively small Xterm window can be expanded at any time with the mouse pointer
After opening, you will see the white cursor behind the command prompt (by default this consists of your user name before the @ and the computer name after the @. You can change the composition of the command prompt in the configuration file of your Linux system). Enter the Linux commands after this prompt.
Tip: Use the key combination CTRL + C to cancel an output in the terminal window. This helps, for example, when a (faulty) command only delivers garbage. In our example we have an image file with cat (with the command cat
you can display the content of simple text files (cat is only suitable for short files), which led to a less meaningful result.
1. Clear: Clean up the input window
After countless entries you have lost the overview and simply want to have the input window nice and empty again: Type in “clear”. Alternative: CTRL + L.
2. Whoami – who am I – and who
Are you unsure what your user name is under which you are logged in ?: “whoami” provides the answer (alternatively you can also enter “who -m”.
Whoami makes sense especially if you frequently switch between different users or root and the user name is not displayed in the command prompt.
Whoami should not be confused with the “who”, which is also useful – it delivers all users currently logged on to your Linux system. After entering who, you can see which user has logged on to which device, on which day and at what time. With “who -a” you force a detailed output, for example by specifying the login time. An alternative to who is the id command.
With the command “last” you can see who was last logged on.
There are these Ubuntu Linux variants
3. pwd: Where am I?
You have lost your bearings and no longer know which directory you are in. The bash command “pwd” helps and shows your current directory.
4. df: Show file system and storage space
The command “df” shows the file system including the memory allocation. For example, you can see at a glance how many hard drives are in your Linux PC and how much space is still free on them. You can also see how each drive is mounted in the directory hierarchy.
In order to increase the readability of the output, you should always type “df” with the parameter “-h”, ie “df -h”: Then the storage space is displayed in Mbyte or Gbyte and not in bytes. With “df -T” in turn the command names the file system for each partition and each data carrier.
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.
5. Passwd: Change password
Even the most secure password should be changed from time to time. And in particular change a password preset by the manufacturer into your own password.
So enter “passwd”. Linux then prompts you to enter your previous password (referred to as Unix password in our example). The entry is invisible. Then you will be asked to enter a new password. Repeat this again – both entries are also made invisible. Your new password already applies (please do not write it down on a Post-it and stick it on the screen).
Console arts: brilliant tricks for the Shell
Warning: Linux distinguishes between upper and lower case. Numbers and hyphens and underscores are allowed, but commas or semicolons are not.
By the way: Linux stores the passwords encrypted in the / etc / shadow file.
The 10 most important Linux commands for network and internet
With normal user rights you can only change your own password with passwd. With root rights you can also change the passwords of all other users: “passwd username” is the command for this. However, the old password no longer has to be specified here. Root can deactivate an account with “passwd – l” (l stands for lock). The reactivation is done with “passwd -u” (u stands for unlock).
6. ls: Show directory
With “ls” you can display all files and directories in the directory in which you are currently located. In our example (an Ubuntu system), directories are marked in blue, but files in white.
You can switch to any directory displayed using the “cd” command (see below). Hidden files and directories are preceded by a “.”
ls -al and above ps aux to display all running processes
The Linux console under control
If you want to know more detailed information about the existing files and directories, enter “ls –al”. Linux then provides you with the file type for each file and directory (for example “-” for files, “d” for directory) information on access rights, the number of hard links (which refer to the file), the owner of a file and Group membership, file size (in bytes) and the last modification date with the time and finally the file or directory name. In addition, the option “a” (for “all”) ensures that system directories are also displayed. The “l” (for long) ensures detailed, long output, with each file and directory on its own line.
7. cd: change directory
With “cd ..” you switch to the next higher directory. If you have got an overview of the existing directories with “ls”, you can switch to each directory displayed with cd DIRECTORY NAME /. You have to pay attention to the exact spelling of the directory name. However, the tab key makes it easier to enter: Type in only the first letter or letters of the desired directory name and then press the TAB key to let Linux complete the name.
Linux for every purpose and every user – the big overview
The command cd without parameters lets you switch to your home directory.
Important: In addition to relative paths (which you enter depending on your current “location” in the directory hierarchy), you can also enter absolute paths: These then always start completely from the root directory, for example: cd / home / Username /Documents.
8. cp: copy and rename
With “cp” you can copy files and entire directories in one go. An example of copying a single file to another directory: “cp file name of target directory”. If you enter a name that does not yet exist instead of the target directory, the file is renamed.
Five reasons against Linux – that’s why the upgrade fails
With “cp –r source directory target directory” you copy a complete directory including the hidden files and the subdirectories.
9. rm: delete files
With “rm” you first delete only files. 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 entry location. And even directories, if they still contain files or other directories and are therefore not empty.
Read tip: Kofler updates Linux – the comprehensive manual
This deletion is done on some systems with a query, but on others without further query, so you can easily accidentally move important files and directories to Nirvana.
Linux on command – smart shell tricks for professionals
Attention: With the command “rm -r
“Sweep all files and directories downwards from your location on the hard drive, explicitly
without the Linux system asking again.
The “f” stands for “force”: Read-only files are also deleted without confirmation.
If you enter this command at the top level, ie with root alias “/”, you will delete your entire Linux system, provided you are logged in as root. But even if you enter this command as a normal user, you will at least destroy all files and directories that belong to you.
If you want to delete files with special characters in their file names, you must put the special characters between single apostrophes, for example: rm ‘#’ * deletes all files in the directory that begin with #.
10. Cat: Quickly view or create a text file
Do you want to quickly view the content of a text file? Then type in “cat file name”. The terminal window then shows you the content of the text file. In the case of text formats that contain complex formatting characters and control characters, the output is sometimes confusing.
For a first overview, the output of cat can be sufficient and simple txt files can even be displayed perfectly.
With the Cat command, you can quickly create a simple text file or view its content.
You can create a short note in simple text format by not having the standard input from the keyboard output on the screen, but by redirecting it to a file: “cat> new file”. Where you replace new file with the desired file name. As soon as you enter this command and press RETURN, the terminal waits for your text. Type it in as you wish, line breaks can be made using RETURN. When you are finished typing, type CTRL + D. This concludes the input, the creation of the text file is ended. Now enter ls as a control. You will now find the new first text file in the directory. With cat filename you display their content.
You can also combine several text files with cat. With this command, you can combine the three text files from our screenshot, namely new_notes, notes and sticky notes into a single file: cat new_notes notes sticky notes> end notes.
Show video description
With the free operating system Linux you can work almost the same as with the paid Windows. In the new edition of Doppelklick you will find out what Linux does and who is worth the switch.