User Tools

Site Tools


Basic commands

System informations

To know name and version of one's Linux distribution:

cat /etc/lsb-release

To get kernel (Architecture) and processor architecture (CPU op-mode(s)):


To view free and used memory:


To view free and used disk space:


To view a detailed description of the system's hardware components:

sudo dmidecode

Switch among directories

To come back from dir/sub-dir to the parent directory dir:

cd ..

To go to any directory:

cd /absolute/path/folder

Visualize content of directory

To visualize the content of a directory:


To visualize hidden files as well:

ls -a

To visualize a detail list of all files (add the option -a to include also the hidden files):

ls -l

with the following output:

type of file permissions hard links owner group size in bytes date last edit name
d folder
- file
owner group other

Create directory

To create a directory with sub-directory:

mkdir folder/sub-folder

Rename directory

To rename a directory:

mv old-name/ new-name/

this will delete the origin folder.

Copy directory

To copy a directory:

cp -r /absolute/path/from /absolute/path/to

this will retain the origin directory.

Delete empty directory

To delete an empty directory:

rmdir folder

Delete non empty directory

To delete a non empty directory:

rm -r folder

Create file

To create a file:

touch file.txt

Rename file

To rename a file:

mv old-file.txt new-file.txt

this will delete the origin file.

Copy file

To copy a file:

cp /aboslute/path/from.txt /absolute/path/to.txt

this will retain the origin file.

Delete file

To delete a file:

rm file.txt

To create a symbolic link (option -s), which points to a file or a directory:

ln -s /absolute/path/origin /absolute/path

Note that a symbolic link is just a path so that if the file or the directory is deleted the link will still work but will point to something that doesn't exist.

Change permissions

The general syntax to change the permissions for a file is:

chmod <options> <people><operator><permission> <file|folder>


<people> <operator> <permission>
u users + add
- remove
= remove previously and set new
r read
w write
x execute
g group
o others

For instance:

chmod ugo=rwx

owner, group and others: read, write and execute

chmod u=rwx

owner: reads, writes and executes (previously permissions for group and others are removed)

chmod u=xw,g=r,o=rw

owner: writes and reads; group: reads; others: reads and writes (for all, previously permissions are replaced with the new ones)

chmod u+r,g-r,o=x

owner: added read permission; group: removed read permission; others: executes

chmod -R o=rw folder

others: reads and writes (permission applied recursively at directory and file)

Execute commands as superuser via graphic mode

To execute commands as superuser via graphic mode, like open folders or open, copy, delete files:

gksudo thunar

thunar is the file manager for Xfce, on Xubuntu. Another file manager is nautilus, for Gnome, on Ubuntu.

It's required the gksu package.

Find string

To find a string:

grep -ilr 'string to find' *


-i case insensitivity
-l list results printing only name files
-r recursive search

Wrap the string in superscripts only if it contains blank spaces.

To save the output in a text file:

grep -ril 'string to find' * > /absolute/path/output.txt

To find a string at the start of a line:

grep -ril '^string to find' /absolute/path

To find a string at the end of a line:

grep -ril 'string to find$' /absolute/path

Find file

To find a file in a directory hierarchy:

find /directory file.txt

Use sudo to search in directories where only the superuser has access.

Processes in execution

To know which processes are in execution:


To stop a process:

kill <PID>

where <PID> is the process's ID read from the output table of the command top.

linux/commands.txt · Last modified: 2020/04/03 09:34 (external edit)