Linux is different, I know you already know that, and if are on this article you’ve taken your first step into the amazin world of Linux OS (little exaggeration).
Here I am going to provide a common command list most commonly used in Linux with their brief introduction.
# 1: cd
The “Change Directory” command enables you to navigate to another directory.
The cd command is THE most important command there is in linux I think. As the command suggests, it enables the user to change / jump to a directory.
pi@raspberrypi: ~$ cd /home/pi
pi@raspberrypi ~$pwd
/home/pi
note: After you have typed cd and entering the first or two letters of the directory you can press the TAB key to autocomplete the directory! so… cd Do (press tabkey) will autocomplete it to Downloads. i use this a lot <–
#2: man
The man command shows the users the “manual” of the command. In some situation you might need to get more information about the command you are using. The man command shows you this information about the command.
pi@raspberrypi: man cp
This will open up the “cp” manual document for us in the shell. The manual shows us the parameters available for the commands.
Note: To close the manual simply press “Q”.
#3: ls
In the absolute top 15 there’s no way the ls command is missing. On the third place, the ls command. The ls command is used to list the files/directories within a directory.
pi@raspberrypi: ~$ ls
Desktop python_games
pi@raspberrypi: ~$
#4: cp
The cp command is available for us to “Copy” things. This might be usefull for duplicating files f.e.
pi@raspberrypi: ~$ cd pifun
[pi@raspberrypi pifun]$ cp pi pi2
[pi@raspberrypi pifun]$ ls
pi pi2 raspberry
[pi@raspberrypi pifun]$
note: file is on this case the file the user wants to be copied… file2 is the name of the copied file. It’s that simple.
#5 mv
The mv command is used for “Move” operations. The mv commands enables the users to move a file/directory to a specified location.
pi@raspberrypi: ~$ cd pifun
[pi@raspberrypi pifun]$ mv pi pi2
[pi@raspberrypi pifun]$ ls
pi2 raspberry
[pi@raspberrypi pifun]$
note: the first part of the command is the file that has to be moved. The second part (after the whitespace) is the target directory. Make sure you type in the full path using this command!
#6 mkdir
This command is used to “make” directories, NOT Files.. (thit is possible with another command which i will bring up later in this tutorial)
pi@raspberrypi: ~$ mkdir pifun
pi@raspberrypi: ~$ mkdir pifun
mkdir: cannot create directory ‘pifun’: File exists
pi@raspberrypi: ~$
note: The name of the directory is case sensitive which means that Testdirectory is a complete different directory as testdirectory.
#7 rmdir
When you are able to make directories, you also want to know how to remove them. Removing directories is done by the rmdir command and belongs to the absolute basic commands in shell bashing.
[pi@raspberrypi pifun]$ rmdir moarpi2
[pi@raspberrypi pifun]$ rm moarpi
rm: cannot remove ‘moarpi’: Is a directory
[pi@raspberrypi pifun]$
note: When the directory is not empty the command will prompt an error message:
rmdir: failed to remove `fiets’: Directory not empty
So make sure it’s completely empty before removing it.
#8 touch
Now we know how to make directories and deleting them, i now want to use the touch command. The touch command is used to make files.
pi@raspberrypi: ~$ touch raspberry
pi@raspberrypi: ~$ touch pi
pi@raspberrypi: ~$ ls
Desktop pi python_games raspberry
pi@raspberrypi: ~$
This will create the file vogel for us in the directory.
#9 rm
The rm command stand for remove. The rm command is used in order the delete files instead of directories.
[pi@raspberrypi pifun]$ rm moarpi
rm: cannot remove ‘moarpi’: Is a directory
[pi@raspberrypi pifun]$
note: To remove files you must have the right permission bits set on the specific file.
#10 tar
Sometimes you have to archive files. Archiving files is a way to pack a set of files to one single file. The operation is done by the tar command.
[pi@raspberrypi pifun]$ tar -cvf test.tar test (Creating a tar file from directory or file test)
[pi@raspberrypi pifun]$ tar -xvf test.tar myexctractfolder (Extracts the particular tar file in the current working directory)
In the example i used parameters. These parameters are telling the tar command how to behave and how to execute. After the parameters i entered the name of the file which is test.tar. The second part is the source directory/file of the tar file. In this situation a directory called test.
#11 pwd
Sometimes you really wonder where you are in the system. PWD is the solution for that problem.
PWD stands for Path Working Directory.
pi@raspberrypi: ~$ pwd
/home/pi
pi@raspberrypi ~$
#12 ifconfig
ifconfig is a command showing you information about the ethernet adapters on your system. It contains very usefull information like gateway, ip, and packet statistics. For the average user this command is rarely used, but i think it’s worth knowing it.
pi@raspberrypi: ifconfig
note: To gain information about the wireless adapters on your system type iwconfig.
#13 locate
Locate is an extremely fast seaching command. It shows the directories or files each on a new line.
pi@raspberrypi: locate syslog
pi@raspberrypi: locate syslog | more (Piping structure used to invert the data from locate to the more command)
note: Some keywords returns enormous ammounts of hits. Use MORE to (see example) clear things up a bit.
#14 ping
Ping is used as a network diagnostic command by professionals. Ping offers information about the network we are on and if the other system responds to us. In cases of troubleshooting network related problems, ping can do a great job to determine the domain of the problem.
pi@raspberrypi: ping www.google.com
The command returns the interval and % of loss during the test.
note: You can stop ping bij pressing crtl-c at the same time.
#15 chmod
The chmod command. The chmod command comes from “Change Mode” back to the unix times. It’s a great command to restrict access to directories or files. But before i show you an example on how to use it, some theory.
Chmod is qiet an advanced command to use. So therefore you really need to understand how it works.
chmod works with so called persmission bits. These bits can be set to a certain level of restrictions.
0 Comments