Basic commands to use in the terminal
In this manual we will learn the basic commands to handle you through the terminal of your Linux server.
CD
As its name indicates, it serves to Change of Directory.
To go to the root of the directory:
cd /
If we want to go to a specific directory:
cd mi_directorio/otro_directorio
To go to the previous directory:
cd ..
LS
With this command we will obtain a "LIST" of the directories and/or files, it would be like an MS-DOS DIR:
ls
You can use the *, which will make the wildcard function:
ls *.txt
It would only show the files with the extension .txt
MKDIR
With this command, you can create a directory:
mkdir nuevo_directorio
RMDIR
Unlike the previous command, it is used to delete directories:
rmdir nuevo_directorio
MV
MV is used to move files, after the command we will put the file we want to move and the destination directory:
mv mi_archivo mi_directorio
RM
RM is used to delete files, if it is accompanied by *, it will delete all files in the directory where you are:
rm mi_archivo
rm *
CLEAR
This command is used to erase the terminal screen:
clear
CP
COPY CP, is used to copy files and directories:
cp archivo copia_archivo
You can make the copy in another directory:
cp archivo /directorio/sub_directorio
DF
DF indicates the disk space, available, used and total:
df -h
DU
DU serves to know the space a file occupies in a directory:
du /mi_directorio
If what you want is to know what occupies the files with the same extension, with -s you can find out:
du -s *.txt
FIND
It serves to find a file, by default the command will show us a list of all the directories and files from the directory where we are:
find -name nombre_archivo
KILL
If something does not work, this command will be helpful. First, we need to know what processes are running:
kill -l
Then we will look at the number of the process that is causing problems and close it:
kill -l 5
MAN
With MAN followed by the command you want, you will get the necessary help, as well as different combinations of the command in question:
man du
SU
It is used to change the user, it will ask you for the password to make the change:
su otro_usuario
EXIT
With this command you will exit the terminal closing it:
exit
Remember that with the dates (above and below) you will get a history of everything you have written in the terminal, saving you, in this way, rewrite it.