Introduction
Linux is a powerful and flexible operating system, with a wide variety of commands for managing and interacting with the system. Knowing Linux commands allows you to perform a variety of tasks, such as manipulating files, creating scripts, managing processes, and much more.
Navigate directories
To move between directories use the cd
command. For example, to get into the "My Documents" directory, run:
cd Documenti
To go back to the previous directory, use the cd..
command:
cd..
Create and remove directories
To create a new directory, use the mkdir
command. For example, to create a directory called "new_folder", run:
mkdir nuova_cartella
To remove an empty directory, use the rmdir
command. For example, to remove the directory called "new_folder", run:
rmdir nuova_cartella
To remove a directory and its contents, use the rm -r
command. Note that this command irreversibly removes files and subdirectories within the directory. For example, to remove the directory called "old_folder" and all of its contents, run:
rm -r vecchia_cartella
View the contents of a directory
The ls
command is used to view the contents of a directory. The basic form of the command returns the names of files and subdirectories within the current directory:
ls
To also view file details, such as permissions, size, and modification dates, use the -l
option:
ls -l
To display all files, including hidden ones (starting with a dot), use the -a
option:
ls -a
Change file permissions
The chmod
command is used to change file access permissions. You can specify permissions as a combination of owner, group and others, using the following letters and symbols:
r
: readingw
: writingx
: run-
: without permission
For example, to grant the owner read and write permission on a file called "my_file", run:
chmod u+rw mio_file
To give all users read permission on the same file, run:
chmod a+r mio_file
To remove write permission from group members, run:
chmod gw mio_file
Manage processes
The ps
command is used to list the processes running on the system. The basic form of the command returns a list of processes related to the current user:
ps
To view all processes in the system, use the -e
option:
ps -e
To kill a running process, use the kill
command. You can specify the process to terminate using its ID or name. For example, to terminate a process with ID 1234, run:
kill 1234
To kill a process using its name, use the killall
command. For example, to kill all processes named "example", run:
killall esempio
Manage files
The cp
command is used to copy a file from one location to another. For example, to copy a file named "my_file" from the current directory to the "My Documents" directory, run:
cp mio_file Documenti/
To move a file instead of copying it, use the mv
command. For example, to move the file "my_file" from the current directory to the "My Documents" directory, run:
mv mio_file Documenti/
To rename a file, use the mv
command to move the renamed file into the same directory. For example, to rename the file "old_name" to "new_name", run:
mv vecchio_nome nuovo_nome
To delete a file, use the rm
command. For example, to delete the file "un_file", run:
rm un_file
Manage the network
The ifconfig
command is used to display information about the system's network configuration. Returns information such as IP address, default gateway, MAC address and much more. Here's how you can use it:
ifconfig
To enable or disable a network interface, use the ifup
or ifdown
command. For example, to enable the "eth0" network interface, run:
sudo ifup eth0
To disable the "eth0" network interface, run:
sudo ifdown eth0
Using the blockchain
Blockchain is a technology that allows for the creation and management of shared digital ledgers. There are various commands and tools for working with the blockchain, depending on the specific platform. For example, to interact with an Ethereum blockchain network, you can use the geth
command or a graphical user interface such as MetaMask
.
To install the geth
client on Ubuntu, run:
sudo apt-get install geth
Then, to start the geth node and connect to the Ethereum network, run:
geth
If you're using a graphical user interface like MetaMask, follow the specific instructions for installing and using it.
Conclusion
In this tutorial, you learned some of the basic commands for mastering Linux. These commands will help you navigate directories, create and remove directories, view directory contents, change file permissions, manage processes, manage files, manage network, and use the blockchain. Experiment with these commands and continue to expand your knowledge to become a Linux operating system expert.