Introduction to the Terminal
Disclaimer: This post has been translated to English using a machine translation model. Please, let me know if you find any mistakes.
Post Format
To avoid having to post console images for every action I take, I have created the following function that receives the terminal command we want to execute and returns the output that the terminal would give us.
Sometimes I will use this function, and other times I will use !
before each command, which in notebooks means that you are going to run a terminal command.
import subprocessimport oslast_directory = ''def terminal(command, max_lines_output=None):global last_directorydebug = Falsestr = command.split()# Check if there are " or ' charactersfor i in range(len(str)):if debug: print(f"i = {i}, str[i] = {str[i]}")if len(str[i]) > 0:if str[i][0] == '"' or str[i][0] == "'":for j in range(i+1,len(str)):if debug: print(f" j = {j}, str[j] = {str[j]}")if str[j][-1] == '"' or str[j][-1] == "'":for k in range(i+1,j+1):if debug: print(f" k = {k}, str[i] = {str[i]}, str[k] = {str[k]}")str[i] = str[i] + " " + str[k]if debug: print(f" k = {k}, str[i] = {str[i]}, str[k] = {str[k]}")str[j:] = [""]str[i] = str[i].replace('"','')# Remove empty stringsstr = [x for x in str if x != ""]if debug:print(str)returnif str[0] == "cd":last_dir = os.getcwd()if len(str) == 1:os.chdir('/home/wallabot')else:if str[1] == "-":os.chdir(last_directory)else:os.chdir(str[1])last_directory = last_direlse:result = subprocess.run(str, stdout=subprocess.PIPE).stdout.decode('utf-8')if max_lines_output is not None:result_split = result.split(' ')print(' '.join(result_split[:max_lines_output]))print(" ...")print(' '.join(result_split[-5:]))else:print(result)
First commands to navigate the terminal
ls
(list directory)
The first command we are going to see is ls
(list directory) which is used to list all the files in the folder we are in.
import subprocessimport oslast_directory = ''def terminal(command, max_lines_output=None):global last_directorydebug = Falsestr = command.split()# Check if there are " or ' charactersfor i in range(len(str)):if debug: print(f"i = {i}, str[i] = {str[i]}")if len(str[i]) > 0:if str[i][0] == '"' or str[i][0] == "'":for j in range(i+1,len(str)):if debug: print(f"\t j = {j}, str[j] = {str[j]}")if str[j][-1] == '"' or str[j][-1] == "'":for k in range(i+1,j+1):if debug: print(f" k = {k}, str[i] = {str[i]}, str[k] = {str[k]}")str[i] = str[i] + " " + str[k]if debug: print(f" k = {k}, str[i] = {str[i]}, str[k] = {str[k]}")str[j:] = [""]str[i] = str[i].replace('"','')# Remove empty stringsstr = [x for x in str if x != ""]if debug:print(str)returnif str[0] == "cd":last_dir = os.getcwd()if len(str) == 1:os.chdir('/home/wallabot')else:if str[1] == "-":os.chdir(last_directory)else:os.chdir(str[1])last_directory = last_direlse:result = subprocess.run(str, stdout=subprocess.PIPE).stdout.decode('utf-8')if max_lines_output is not None:result_split = result.split('\n')print('\n'.join(result_split[:max_lines_output]))print("\t ...")print('\n'.join(result_split[-5:]))else:print(result)terminal("ls")
2021-02-11-Introduccion-a-Python.ipynb2021-04-23-Calculo-matricial-con-Numpy.ipynb2021-06-15-Manejo-de-datos-con-Pandas.ipynb2022-09-12 Introduccion a la terminal.ipynb2022-09-12 Introduccion a la terminal.txtcommand-line-cheat-sheet.pdfCSS.ipynbDocker.htmlDocker.ipynbExpresiones regulares.htmlExpresiones regulares.ipynbhtml_fileshtml.ipynbintroduccion_pythonmovies.csvmovies.datnotebooks_translated__pycache__ssh.ipynbtest.htmltest.ipynb
Commands can usually receive options (flags
), which are introduced with the -
character. For example, let's look at ls -l
, which returns the list of files in the directory we are in, but with more information.
terminal('ls -l')
total 4512-rw-rw-r-- 1 wallabot wallabot 285898 nov 12 02:07 2021-02-11-Introduccion-a-Python.ipynb-rw-rw-r-- 1 wallabot wallabot 78450 nov 13 00:10 2021-04-23-Calculo-matricial-con-Numpy.ipynb-rw-rw-r-- 1 wallabot wallabot 484213 nov 13 00:44 2021-06-15-Manejo-de-datos-con-Pandas.ipynb-rw-rw-r-- 1 wallabot wallabot 320810 dic 6 00:11 2022-09-12 Introduccion a la terminal.ipynb-rw-rw-r-- 1 wallabot wallabot 320594 dic 6 00:04 2022-09-12 Introduccion a la terminal.txt-rw-rw-r-- 1 wallabot wallabot 119471 oct 3 16:13 command-line-cheat-sheet.pdf-rw-rw-r-- 1 wallabot wallabot 2660 sep 18 03:32 CSS.ipynb-rw-rw-r-- 1 wallabot wallabot 699225 nov 27 04:16 Docker.html-rw-rw-r-- 1 wallabot wallabot 509125 sep 22 16:48 Docker.ipynb-rw-rw-r-- 1 wallabot wallabot 156193 nov 27 04:21 Expresiones regulares.html-rw-rw-r-- 1 wallabot wallabot 53094 oct 2 04:57 Expresiones regulares.ipynbdrwxrwxr-x 2 wallabot wallabot 4096 nov 28 14:39 html_files-rw-rw-r-- 1 wallabot wallabot 14775 sep 18 03:29 html.ipynbdrwxrwxr-x 3 wallabot wallabot 4096 nov 12 01:51 introduccion_python-rw-rw-r-- 1 wallabot wallabot 446172 oct 2 04:39 movies.csv-rw-rw-r-- 1 wallabot wallabot 522197 oct 2 04:33 movies.datdrwxrwxr-x 2 wallabot wallabot 4096 nov 28 14:39 notebooks_translateddrwxrwxr-x 2 wallabot wallabot 4096 ago 27 03:25 __pycache__-rw-rw-r-- 1 wallabot wallabot 586 dic 4 02:31 ssh.ipynb-rw-rw-r-- 1 wallabot wallabot 292936 nov 9 01:46 test.html-rw-rw-r-- 1 wallabot wallabot 260227 nov 9 01:13 test.ipynb
As we can see, we have how many bytes each file occupies, but when we have files that take up a lot of space, this is not very easy to read, so we can add the h
(human
) option that gives us easier to read information.
terminal('ls -lh')
total 4,5M-rw-rw-r-- 1 wallabot wallabot 280K nov 12 02:07 2021-02-11-Introduccion-a-Python.ipynb-rw-rw-r-- 1 wallabot wallabot 77K nov 13 00:10 2021-04-23-Calculo-matricial-con-Numpy.ipynb-rw-rw-r-- 1 wallabot wallabot 473K nov 13 00:44 2021-06-15-Manejo-de-datos-con-Pandas.ipynb-rw-rw-r-- 1 wallabot wallabot 314K dic 6 00:11 2022-09-12 Introduccion a la terminal.ipynb-rw-rw-r-- 1 wallabot wallabot 314K dic 6 00:04 2022-09-12 Introduccion a la terminal.txt-rw-rw-r-- 1 wallabot wallabot 117K oct 3 16:13 command-line-cheat-sheet.pdf-rw-rw-r-- 1 wallabot wallabot 2,6K sep 18 03:32 CSS.ipynb-rw-rw-r-- 1 wallabot wallabot 683K nov 27 04:16 Docker.html-rw-rw-r-- 1 wallabot wallabot 498K sep 22 16:48 Docker.ipynb-rw-rw-r-- 1 wallabot wallabot 153K nov 27 04:21 Expresiones regulares.html-rw-rw-r-- 1 wallabot wallabot 52K oct 2 04:57 Expresiones regulares.ipynbdrwxrwxr-x 2 wallabot wallabot 4,0K nov 28 14:39 html_files-rw-rw-r-- 1 wallabot wallabot 15K sep 18 03:29 html.ipynbdrwxrwxr-x 3 wallabot wallabot 4,0K nov 12 01:51 introduccion_python-rw-rw-r-- 1 wallabot wallabot 436K oct 2 04:39 movies.csv-rw-rw-r-- 1 wallabot wallabot 510K oct 2 04:33 movies.datdrwxrwxr-x 2 wallabot wallabot 4,0K nov 28 14:39 notebooks_translateddrwxrwxr-x 2 wallabot wallabot 4,0K ago 27 03:25 __pycache__-rw-rw-r-- 1 wallabot wallabot 586 dic 4 02:31 ssh.ipynb-rw-rw-r-- 1 wallabot wallabot 287K nov 9 01:46 test.html-rw-rw-r-- 1 wallabot wallabot 255K nov 9 01:13 test.ipynb
If we want to see hidden files, we can use the a
option, which will show us all the files in a directory
terminal('ls -lha')
total 4,5Mdrwxrwxr-x 6 wallabot wallabot 4,0K dic 6 00:04 .drwxrwxr-x 5 wallabot wallabot 4,0K oct 2 03:10 ..-rw-rw-r-- 1 wallabot wallabot 280K nov 12 02:07 2021-02-11-Introduccion-a-Python.ipynb-rw-rw-r-- 1 wallabot wallabot 77K nov 13 00:10 2021-04-23-Calculo-matricial-con-Numpy.ipynb-rw-rw-r-- 1 wallabot wallabot 473K nov 13 00:44 2021-06-15-Manejo-de-datos-con-Pandas.ipynb-rw-rw-r-- 1 wallabot wallabot 314K dic 6 00:11 2022-09-12 Introduccion a la terminal.ipynb-rw-rw-r-- 1 wallabot wallabot 314K dic 6 00:04 2022-09-12 Introduccion a la terminal.txt-rw-rw-r-- 1 wallabot wallabot 117K oct 3 16:13 command-line-cheat-sheet.pdf-rw-rw-r-- 1 wallabot wallabot 2,6K sep 18 03:32 CSS.ipynb-rw-rw-r-- 1 wallabot wallabot 683K nov 27 04:16 Docker.html-rw-rw-r-- 1 wallabot wallabot 498K sep 22 16:48 Docker.ipynb-rw-rw-r-- 1 wallabot wallabot 153K nov 27 04:21 Expresiones regulares.html-rw-rw-r-- 1 wallabot wallabot 52K oct 2 04:57 Expresiones regulares.ipynbdrwxrwxr-x 2 wallabot wallabot 4,0K nov 28 14:39 html_files-rw-rw-r-- 1 wallabot wallabot 15K sep 18 03:29 html.ipynbdrwxrwxr-x 3 wallabot wallabot 4,0K nov 12 01:51 introduccion_python-rw-rw-r-- 1 wallabot wallabot 436K oct 2 04:39 movies.csv-rw-rw-r-- 1 wallabot wallabot 510K oct 2 04:33 movies.datdrwxrwxr-x 2 wallabot wallabot 4,0K nov 28 14:39 notebooks_translateddrwxrwxr-x 2 wallabot wallabot 4,0K ago 27 03:25 __pycache__-rw-rw-r-- 1 wallabot wallabot 586 dic 4 02:31 ssh.ipynb-rw-rw-r-- 1 wallabot wallabot 287K nov 9 01:46 test.html-rw-rw-r-- 1 wallabot wallabot 255K nov 9 01:13 test.ipynb
If what we want is for it to sort them by size, we can use the S
option
terminal('ls -lhS')
total 4,5M-rw-rw-r-- 1 wallabot wallabot 683K nov 27 04:16 Docker.html-rw-rw-r-- 1 wallabot wallabot 510K oct 2 04:33 movies.dat-rw-rw-r-- 1 wallabot wallabot 498K sep 22 16:48 Docker.ipynb-rw-rw-r-- 1 wallabot wallabot 473K nov 13 00:44 2021-06-15-Manejo-de-datos-con-Pandas.ipynb-rw-rw-r-- 1 wallabot wallabot 436K oct 2 04:39 movies.csv-rw-rw-r-- 1 wallabot wallabot 314K dic 6 00:11 2022-09-12 Introduccion a la terminal.ipynb-rw-rw-r-- 1 wallabot wallabot 314K dic 6 00:04 2022-09-12 Introduccion a la terminal.txt-rw-rw-r-- 1 wallabot wallabot 287K nov 9 01:46 test.html-rw-rw-r-- 1 wallabot wallabot 280K nov 12 02:07 2021-02-11-Introduccion-a-Python.ipynb-rw-rw-r-- 1 wallabot wallabot 255K nov 9 01:13 test.ipynb-rw-rw-r-- 1 wallabot wallabot 153K nov 27 04:21 Expresiones regulares.html-rw-rw-r-- 1 wallabot wallabot 117K oct 3 16:13 command-line-cheat-sheet.pdf-rw-rw-r-- 1 wallabot wallabot 77K nov 13 00:10 2021-04-23-Calculo-matricial-con-Numpy.ipynb-rw-rw-r-- 1 wallabot wallabot 52K oct 2 04:57 Expresiones regulares.ipynb-rw-rw-r-- 1 wallabot wallabot 15K sep 18 03:29 html.ipynbdrwxrwxr-x 2 wallabot wallabot 4,0K nov 28 14:39 html_filesdrwxrwxr-x 3 wallabot wallabot 4,0K nov 12 01:51 introduccion_pythondrwxrwxr-x 2 wallabot wallabot 4,0K nov 28 14:39 notebooks_translateddrwxrwxr-x 2 wallabot wallabot 4,0K ago 27 03:25 __pycache__-rw-rw-r-- 1 wallabot wallabot 2,6K sep 18 03:32 CSS.ipynb-rw-rw-r-- 1 wallabot wallabot 586 dic 4 02:31 ssh.ipynb
If we want it to show us the files sorted alphabetically but in reverse order, we must use the -r
option
terminal('ls -lhr')
total 4,5M-rw-rw-r-- 1 wallabot wallabot 255K nov 9 01:13 test.ipynb-rw-rw-r-- 1 wallabot wallabot 287K nov 9 01:46 test.html-rw-rw-r-- 1 wallabot wallabot 586 dic 4 02:31 ssh.ipynbdrwxrwxr-x 2 wallabot wallabot 4,0K ago 27 03:25 __pycache__drwxrwxr-x 2 wallabot wallabot 4,0K nov 28 14:39 notebooks_translated-rw-rw-r-- 1 wallabot wallabot 510K oct 2 04:33 movies.dat-rw-rw-r-- 1 wallabot wallabot 436K oct 2 04:39 movies.csvdrwxrwxr-x 3 wallabot wallabot 4,0K nov 12 01:51 introduccion_python-rw-rw-r-- 1 wallabot wallabot 15K sep 18 03:29 html.ipynbdrwxrwxr-x 2 wallabot wallabot 4,0K nov 28 14:39 html_files-rw-rw-r-- 1 wallabot wallabot 52K oct 2 04:57 Expresiones regulares.ipynb-rw-rw-r-- 1 wallabot wallabot 153K nov 27 04:21 Expresiones regulares.html-rw-rw-r-- 1 wallabot wallabot 498K sep 22 16:48 Docker.ipynb-rw-rw-r-- 1 wallabot wallabot 683K nov 27 04:16 Docker.html-rw-rw-r-- 1 wallabot wallabot 2,6K sep 18 03:32 CSS.ipynb-rw-rw-r-- 1 wallabot wallabot 117K oct 3 16:13 command-line-cheat-sheet.pdf-rw-rw-r-- 1 wallabot wallabot 314K dic 6 00:04 2022-09-12 Introduccion a la terminal.txt-rw-rw-r-- 1 wallabot wallabot 314K dic 6 00:11 2022-09-12 Introduccion a la terminal.ipynb-rw-rw-r-- 1 wallabot wallabot 473K nov 13 00:44 2021-06-15-Manejo-de-datos-con-Pandas.ipynb-rw-rw-r-- 1 wallabot wallabot 77K nov 13 00:10 2021-04-23-Calculo-matricial-con-Numpy.ipynb-rw-rw-r-- 1 wallabot wallabot 280K nov 12 02:07 2021-02-11-Introduccion-a-Python.ipynb
cd
(change directory)
The second command will be cd
(change directory) which allows us to change directories
terminal('cd /home/wallabot/Documentos/')
If we now use ls
again to see the files we have, we see that they change
terminal('cd /home/wallabot/Documentos/')terminal('ls')
aprendiendo-git.pdfbalena-etcher-electron-1.7.9-linux-x64camerasIPDocumentaciongstreamergstreamer_oldjetsonNanokaggleLibrosnerfprueba.txtpytorchwallabotweb
If instead of giving cd
the directory we want to move to, we give it the character -
, it will return to the previous directory where it was.
terminal('cd -')
terminal('cd -')terminal('ls')
2021-02-11-Introduccion-a-Python.ipynb2021-04-23-Calculo-matricial-con-Numpy.ipynb2021-06-15-Manejo-de-datos-con-Pandas.ipynb2022-09-12 Introduccion a la terminal.ipynb2022-09-12 Introduccion a la terminal.txtcommand-line-cheat-sheet.pdfCSS.ipynbDocker.htmlDocker.ipynbExpresiones regulares.htmlExpresiones regulares.ipynbhtml_fileshtml.ipynbintroduccion_pythonmovies.csvmovies.datnotebooks_translated__pycache__ssh.ipynbtest.htmltest.ipynb
If we wanted to move to the home
, just entering cd
in the terminal will take us there.
terminal('cd')
pwd
(print working directory)
To obtain the directory we are in, we can use pwd
(print working directory)
terminal('cd')terminal('pwd')
/home/wallabot
We can move using the cd
command via relative paths and absolute paths. For example, let's move to a directory using an absolute path.
terminal('cd /home/wallabot/Documentos/')
terminal('cd /home/wallabot/Documentos/')terminal('pwd')
/home/wallabot/Documentos
terminal('ls')
aprendiendo-git.pdfbalena-etcher-electron-1.7.9-linux-x64camerasIPDocumentaciongstreamergstreamer_oldjetsonNanokaggleLibrosnerfprueba.txtpytorchwallabotweb
We can move using relative paths if we only provide the address from the point where we are located.
terminal('cd web')
terminal('cd web')terminal('pwd')
/home/wallabot/Documentos/web
We can also go up one directory using relative paths with ..
terminal('cd ..')
terminal('cd ..')terminal('pwd')
/home/wallabot/Documentos
If instead of ..
we use .
, we are referring to the directory we are currently in. That is, if we use cd .
, we will not move because we are telling the terminal to go to the directory we are in.
terminal('cd .')
terminal('cd .')terminal('pwd')
/home/wallabot/Documentos
Let's move to a path where we have files to display the following command
terminal('cd web/portafolio/posts/')
terminal('cd web/portafolio/posts/')terminal('ls')
2021-02-11-Introduccion-a-Python.ipynb2021-04-23-Calculo-matricial-con-Numpy.ipynb2021-06-15-Manejo-de-datos-con-Pandas.ipynb2022-09-12 Introduccion a la terminal.ipynb2022-09-12 Introduccion a la terminal.txtcommand-line-cheat-sheet.pdfCSS.ipynbDocker.htmlDocker.ipynbExpresiones regulares.htmlExpresiones regulares.ipynbhtml_fileshtml.ipynbintroduccion_pythonmovies.csvmovies.datnotebooks_translated__pycache__ssh.ipynbtest.htmltest.ipynb
Information of files with file
If I don't know what type of file a particular one is, I can get a description using the file
command
terminal('file 2021-02-11-Introduccion-a-Python.ipynb')
2021-02-11-Introduccion-a-Python.ipynb: UTF-8 Unicode text, with very long lines
Manipulating files and directories
Let's move first to the home.
terminal('cd /home/wallabot/Documentos/')
Directory Tree with tree
We can see the entire structure of the folder we are in using the tree
command.
terminal('cd /home/wallabot/Documentos/')terminal('tree', max_lines_output=20)
.├── aprendiendo-git.pdf├── balena-etcher-electron-1.7.9-linux-x64│ └── balenaEtcher-1.7.9-x64.AppImage├── camerasIP│ ├── camerasIP.py│ ├── camerasIP.sh│ ├── config.py│ ├── __pycache__│ │ ├── config.cpython-38.pyc│ │ └── config.cpython-39.pyc│ └── README.md├── Documentacion│ ├── Curriculum Vitae (5).pdf│ ├── Firma Pris.PNG│ └── Firma.png├── gstreamer│ ├── basic_tutorial_c│ │ ├── basic_tutorial_1_hello_world│ │ │ ├── basic-tutorial-1...├── upload_page.py└── utils.py873 directories, 119679 files
But at the output, we have too many lines, and this is because tree
is a command that shows all the files from the path we are in, making it a bit hard to read. However, with the L
option, we can specify how many levels we want it to go deep.
terminal('tree -L 2')
.├── aprendiendo-git.pdf├── balena-etcher-electron-1.7.9-linux-x64│ └── balenaEtcher-1.7.9-x64.AppImage├── camerasIP│ ├── camerasIP.py│ ├── camerasIP.sh│ ├── config.py│ ├── __pycache__│ └── README.md├── Documentacion│ ├── Curriculum Vitae (5).pdf│ ├── Firma Pris.PNG│ └── Firma.png├── gstreamer│ ├── basic_tutorial_c│ └── README.md├── gstreamer_old│ ├── basic_tutorial_c│ └── basic_tutorial_python├── jetsonNano│ ├── apuntes-Jetson-Nano│ ├── deepstream_apps│ ├── deepstream_nano│ └── Digital zoom├── kaggle│ └── hubmap├── Libros│ └── aprendiendo-git.pdf├── nerf│ └── instant-ngp├── prueba.txt├── pytorch│ └── Curso_Pytorch├── wallabot│ ├── Microfono - Blue Yeti X│ ├── placa base - Asus prime x570-p│ └── Silla - Corsair T3 Rush└── web├── jupyter-to-html├── jupyter-translator├── portafolio└── wordpress_api_rest30 directories, 12 files
We can see that it shows there are 30 directories and 12 files, whereas previously it indicated 873 directories, 119679 files.
Create directories with mkdir
(make directory)
If we want to create a new directory, we can use the mkdir
(make directory) command followed by a name
terminal("cd /home/wallabot/Documentos/web/portafolio/posts/")
terminal("cd /home/wallabot/Documentos/web/portafolio/posts/")terminal('mkdir prueba')
terminal('ls')
2021-02-11-Introduccion-a-Python.ipynb2021-04-23-Calculo-matricial-con-Numpy.ipynb2021-06-15-Manejo-de-datos-con-Pandas.ipynb2022-09-12 Introduccion a la terminal.ipynb2022-09-12 Introduccion a la terminal.txtcommand-line-cheat-sheet.pdfCSS.ipynbDocker.htmlDocker.ipynbExpresiones regulares.htmlExpresiones regulares.ipynbhtml_fileshtml.ipynbintroduccion_pythonmovies.csvmovies.datnotebooks_translatedprueba__pycache__ssh.ipynbtest.htmltest.ipynb
If we want to create a directory with spaces in the name, we need to put the name in quotes.
terminal('mkdir "directorio prueba"')
terminal('ls')
2021-02-11-Introduccion-a-Python.ipynb2021-04-23-Calculo-matricial-con-Numpy.ipynb2021-06-15-Manejo-de-datos-con-Pandas.ipynb2022-09-12 Introduccion a la terminal.ipynb2022-09-12 Introduccion a la terminal.txtcommand-line-cheat-sheet.pdfCSS.ipynbdirectorio pruebaDocker.htmlDocker.ipynbExpresiones regulares.htmlExpresiones regulares.ipynbhtml_fileshtml.ipynbintroduccion_pythonmovies.csvmovies.datnotebooks_translatedprueba__pycache__ssh.ipynbtest.htmltest.ipynb
Let's go inside the prueba
folder that we have created, to continue viewing the terminal there.
terminal("cd prueba")
Create files with touch
In case we want to create a file, the command we have to use is touch
terminal("cd prueba")terminal("touch prueba.txt")
terminal("ls")
prueba.txt
Copy Files with cp
(copy)
If we want to copy a file, we do it using the cp
(copy) command
terminal("cp prueba.txt prueba_copy.txt")
terminal("ls")
prueba_copy.txtprueba.txt
Move files with mv
(move)
If what we want is to move it, what we use is the mv
(move) command
terminal("mv prueba.txt ../prueba.txt")
terminal("ls")
prueba_copy.txt
terminal("ls ../")
2021-02-11-Introduccion-a-Python.ipynb2021-04-23-Calculo-matricial-con-Numpy.ipynb2021-06-15-Manejo-de-datos-con-Pandas.ipynb2022-09-12 Introduccion a la terminal.ipynb2022-09-12 Introduccion a la terminal.txtcommand-line-cheat-sheet.pdfCSS.ipynbdirectorio pruebaDocker.htmlDocker.ipynbExpresiones regulares.htmlExpresiones regulares.ipynbhtml_fileshtml.ipynbintroduccion_pythonmovies.csvmovies.datnotebooks_translatedpruebaprueba.txt__pycache__ssh.ipynbtest.htmltest.ipynb
Rename files with mv
(move)
The mv
command also helps us rename files, as moving them within the same directory but giving them a different name ultimately renames the file.
terminal("mv prueba_copy.txt prueba_move.txt")
terminal("ls")
prueba_move.txt
Delete files with rm
(remove)
To delete files or directories we use the rm
(remove) command
terminal("rm prueba_move.txt")
terminal("ls")
Delete directories with rm -r
(remove recursive)
If what we want is to delete a directory with files inside, we must use the -r
flag.
terminal("cd ..")
terminal("cd ..")terminal('rm -r "directorio prueba"')
terminal("ls")
2021-02-11-Introduccion-a-Python.ipynb2021-04-23-Calculo-matricial-con-Numpy.ipynb2021-06-15-Manejo-de-datos-con-Pandas.ipynb2022-09-12 Introduccion a la terminal.ipynb2022-09-12 Introduccion a la terminal.txtcommand-line-cheat-sheet.pdfCSS.ipynbDocker.htmlDocker.ipynbExpresiones regulares.htmlExpresiones regulares.ipynbhtml_fileshtml.ipynbintroduccion_pythonmovies.csvmovies.datnotebooks_translatedpruebaprueba.txt__pycache__ssh.ipynbtest.htmltest.ipynb
As you can see it never asks if we are sure, to make it ask we need to add the flag -i
(interactive
)
terminal("rm -i prueba.txt")
rm: ¿borrar el fichero regular vacío 'prueba.txt'? (s/n) s
Synchronize files using rsync
So far we have seen how to copy, move, and delete files, but let's suppose we have a folder and we copy those files to another one. Now let's suppose we modify a file in the first folder and we want the second one to have the changes. We have two options, copy all the files again, or synchronize them using rsync
First, let's create a new folder in which we will create several files
!mkdir sourcefolder!touch sourcefolder/file1 sourcefolder/file2 sourcefolder/file3
Now we create a second folder which is the one we are going to synchronize with the first one.
!mkdir sourcefolder!touch sourcefolder/file1 sourcefolder/file2 sourcefolder/file3!mkdir syncfolder
!mkdir sourcefolder!touch sourcefolder/file1 sourcefolder/file2 sourcefolder/file3!mkdir syncfolder!echo "ls sourcefolder:" && ls sourcefolder && echo "ls syncfolder:" && ls syncfolder
ls sourcefolder:file1 file2 file3ls syncfolder:
We synchronize the two folders with rsync
, the first time it will only copy the files from the first folder to the second. To do this, we must also add the -r
(recursive) flag.
!rsync -r sourcefolder/ syncfolder/
!rsync -r sourcefolder/ syncfolder/!echo "ls sourcefolder:" && ls sourcefolder && echo "ls syncfolder:" && ls syncfolder
ls sourcefolder:file1 file2 file3ls syncfolder:file1 file2 file3
If I now create a new file in sourcefolder
and sync again, only that file will be copied to syncfolder
. To see that only one file is copied, we can use the -v
(verbose) flag.
!touch sourcefolder/file4
!touch sourcefolder/file4!rsync -r -v sourcefolder/ syncfolder/
sending incremental file listfile1file2file3file4sent 269 bytes received 92 bytes 722.00 bytes/sectotal size is 0 speedup is 0.00
But it seems that it has copied all the files, so to prevent this from happening and to copy only the ones that have been modified, you need to use the -u
flag.
!touch sourcefolder/file5
!touch sourcefolder/file5!rsync -r -v -u sourcefolder/ syncfolder/
sending incremental file listfile5sent 165 bytes received 35 bytes 400.00 bytes/sectotal size is 0 speedup is 0.00
!echo "ls sourcefolder:" && ls sourcefolder && echo "ls syncfolder:" && ls syncfolder
ls sourcefolder:file1 file2 file3 file4 file5ls syncfolder:file1 file2 file3 file4 file5
What happens if I create a new file in syncfolder
?
!touch syncfolder/file6
!touch syncfolder/file6!rsync -r -v -u sourcefolder/ syncfolder/
sending incremental file listsent 122 bytes received 12 bytes 268.00 bytes/sectotal size is 0 speedup is 0.00
!echo "ls sourcefolder:" && ls sourcefolder && echo "ls syncfolder:" && ls syncfolder
ls sourcefolder:file1 file2 file3 file4 file5ls syncfolder:file1 file2 file3 file4 file5 file6
It doesn't sync it, so it's important to keep this in mind
Some important flags to keep in mind are:
-a
: This flag is a shortcut for several options, including-r
(recursive),-l
(copy symbolic links),-p
(preserve permissions),-t
(preserve modification time), and-g
(preserve group). This option is useful for making an exact copy of a directory, including all its subdirectories and files.*-v
: This flag activates verbose output, which shows the files being copied and the progress of the operation. *-r
: This flag is used to copy recursively, which means it copies all subfolders and files within a directory. *-u
: This flag is used to copy only the new or modified files. If a file already exists at the destination and is more recent than the source file, it is not copied. *-n
: This flag is used to perform a dry run, which means no changes are made to the destination. *--exclude
: This flag is used to exclude specific files or folders from the copy operation. You can specify multiple files or folders to exclude by using this option multiple times. *-z
: This flag is used to compress the data during transfer, which reduces the bandwidth used and speeds up the transfer rate.*-h
: this flag is used to display information in a more readable format, especially when working with large amounts of data or large file sizes.
We delete the two created folders
!rm -r sourcefolder syncfolder
Exploring the Content of the Files
To avoid having to open a file from a graphical interface, we have several ways. First, I am going to copy a text file into this folder.
!rm -r sourcefolder syncfolderterminal("cd prueba")
!rm -r sourcefolder syncfolderterminal("cd prueba")terminal("cp ../2021-02-11-Introduccion-a-Python.ipynb .")
terminal("ls")
2021-02-11-Introduccion-a-Python.ipynb
File Header with head
The first command to be able to look inside a text file is head
, which allows us to see the first 10 lines of a file, but if you use the -n
flag you can indicate the number of lines.
terminal("head 2021-02-11-Introduccion-a-Python.ipynb")
{"cells": [{"cell_type": "markdown","metadata": {"id": "dsaKCKL0IxZl"},"source": ["# Introducción a Python"]
terminal("head -n 5 2021-02-11-Introduccion-a-Python.ipynb")
{"cells": [{"cell_type": "markdown","metadata": {
End of a file with tail
In case you want to see the last lines, we use tail
terminal("tail 2021-02-11-Introduccion-a-Python.ipynb")
},"vscode": {"interpreter": {"hash": "d5745ab6aba164e1152437c779991855725055592b9f2bdb41a4825db7168d26"}}},"nbformat": 4,"nbformat_minor": 0}
terminal("tail -n 5 2021-02-11-Introduccion-a-Python.ipynb")
}},"nbformat": 4,"nbformat_minor": 0}
If we want to continuously see the latest lines of a file, for example, we want to continuously monitor a LOG file to see events, we add the -f
flag, this will make the terminal continuously check the file, and each time a new line appears in it, it will display it.
For example, if I monitor the login log on my machine
!tail -f /var/log/auth.log
Dec 1 16:27:22 wallabot gcr-prompter[1457]: Gcr: calling the PromptDone method on /org/gnome/keyring/Prompt/p2@:1.26, and ignoring replyDec 1 16:27:22 wallabot gnome-keyring-daemon[1178]: asked to register item /org/freedesktop/secrets/collection/login/10, but it's already registeredDec 1 16:27:26 wallabot systemd-logind[835]: Watching system buttons on /dev/input/event28 (Logitech Wireless Mouse MX Master 3)Dec 1 16:27:33 wallabot gcr-prompter[1457]: Gcr: 10 second inactivity timeout, quittingDec 1 16:27:33 wallabot gcr-prompter[1457]: Gcr: unregistering prompterDec 1 16:27:33 wallabot gcr-prompter[1457]: Gcr: disposing prompterDec 1 16:27:33 wallabot gcr-prompter[1457]: Gcr: finalizing prompterDec 1 16:27:34 wallabot polkitd(authority=local): Operator of unix-session:1 successfully authenticated as unix-user:wallabot to gain TEMPORARY authorization for action org.debian.apt.install-or-remove-packages for system-bus-name::1.96 [/usr/bin/python3 /usr/bin/update-manager --no-update --no-focus-on-map] (owned by unix-user:wallabot)Dec 1 16:27:42 wallabot systemd-logind[835]: Watching system buttons on /dev/input/event30 (T9-R (AVRCP))Dec 1 16:27:49 wallabot gnome-keyring-daemon[1178]: asked to register item /org/freedesktop/secrets/collection/login/2, but it's already registered
We see in the last two lines my login when I turned on my computer today.
Now I connect to my own machine via SSH
!ssh localhost
wallabot@localhost's password:Welcome to Ubuntu 20.04.5 LTS (GNU/Linux 5.15.0-53-generic x86_64)* Documentation: https://help.ubuntu.com* Management: https://landscape.canonical.com* Support: https://ubuntu.com/advantage1 device has a firmware upgrade available.Run `fwupdmgr get-upgrades` for more information.Se pueden aplicar 0 actualizaciones de forma inmediata.Your Hardware Enablement Stack (HWE) is supported until April 2025.*** System restart required ***Last login: Sun May 8 02:18:09 2022 from 192.168.1.147
In the console where I was monitoring the login, two new lines have appeared
Dec 1 16:32:23 wallabot sshd[25647]: Accepted password for wallabot from 127.0.0.1 port 54668 ssh2Dec 1 16:32:23 wallabot sshd[25647]: pam_unix(sshd:session): session opened for user wallabot by (uid=0)Dec 1 16:32:23 wallabot systemd-logind[835]: New session 4 of user wallabot.
And when I close the SSH session, two new lines appear.
Dec 1 16:33:52 wallabot sshd[25647]: pam_unix(sshd:session): session closed for user wallabotDec 1 16:33:52 wallabot systemd-logind[835]: Session 4 logged out. Waiting for processes to exit.Dec 1 16:33:52 wallabot systemd-logind[835]: Removed session 4.
The most powerful file viewer: less
One of the most powerful commands to view inside files is less
terminal("less 2021-02-11-Introduccion-a-Python.ipynb", max_lines_output=20)
{"cells": [{"cell_type": "markdown","metadata": {"id": "dsaKCKL0IxZl"},"source": ["# Introducción a Python"]},{"cell_type": "markdown","metadata": {"id": "Ho_8zgIiI0We"},"source": ["## 1. Resumen"]},...},"nbformat": 4,"nbformat_minor": 0}
Being inside a notebook, you can't really see what happens when using less
, but when we use it, we enter the document, and we can navigate through it using the keyboard or the mouse.
If we want to search for something within the document, we write the character /
and what we want to search for. To switch between the different instances it has found, we press the n
key, and if we want to go back in the searches, we press shift+n
.
To exit, just press q
The cat
viewer
It does not allow you to browse the file or perform searches.
terminal("cat 2021-02-11-Introduccion-a-Python.ipynb", max_lines_output=20)
{"cells": [{"cell_type": "markdown","metadata": {"id": "dsaKCKL0IxZl"},"source": ["# Introducción a Python"]},{"cell_type": "markdown","metadata": {"id": "Ho_8zgIiI0We"},"source": ["## 1. Resumen"]},...},"nbformat": 4,"nbformat_minor": 0}
Default system editor xdg-open
If we want to open it with the file's default editor, we need to use xdg-open
terminal("xdg-open 2021-02-11-Introducción-a-Python.ipynb")
File manager nautilus
If what we want is to open the folder we are in, we use nautilus
terminal("nautilus")
And if what we want is for it to open in a specific path, the path is included.
terminal("nautilus ~/")
Word count of a file with wc
(word count)
Finally, a very useful command is wc
(word count), which shows you how many lines, words, and bytes a file has
terminal("wc 2021-02-11-Introduccion-a-Python.ipynb")
11678 25703 285898 2021-02-11-Introduccion-a-Python.ipynb
As we can see, the file has 11678 lines, 25703 words, and occupies 285898 bytes.
What is a command
A command can be four things* An executable program, these are usually stored in the /usr/bin
path* A shell command * A shell function * An alias
To see which class a command belongs to, we use type
!type cd
cd is a shell builtin
!type mkdir
mkdir is /usr/bin/mkdir
!type ls
ls is /usr/bin/ls
What is an alias?
An alias is a command that we define ourselves, it is defined using the alias
command. For example, we are going to create the alias l
that will perform ls -h
!alias l='ls -l'
When we execute l
, it shows us the result of ls -h
.
!alias l='ls -l'!l
2021-02-11-Introducción-a-Python.ipynb
But this has the problem that when we close the terminal, the alias
disappears. Later we will learn how to create permanent alias
.
Command Help
Help with help
With many shell commands, we can get their help using the help
command
!help cd
cd: cd [-L|[-P [-e]]] [dir]Modifica el directorio de trabajo del shell.Modifica el directorio actual a DIR. DIR por defecto es el valor de lavariable de shell HOME.La variable CDPATH define la ruta de búsqueda para el directorio quecontiene DIR. Los nombres alternativos de directorio en CDPATH seseparan con dos puntos (:). Un nombre de directorio nulo es igual queel directorio actual. Si DIR comienza con una barra inclinada (/),entonces no se usa CDPATH.Si no se encuentra el directorio, y la opción del shell "cdable_vars"está activa, entonces se trata la palabra como un nombre de variable.Si esa variable tiene un valor, se utiliza su valor para DIR.Opciones:-L fuerza a seguir los enlaces simbólicos: resuelve los enlacessimbólicos en DIR después de procesar las instancias de ".."-P usa la estructura física de directorios sin seguir los enlacessimbólicos: resuelve los enlaces simbólicos en DIR antes de procesarlas instancias de ".."-e si se da la opción -P y el directorio actual de trabajo no sepuede determinar con éxito, termina con un estado diferente de cero.La acción por defecto es seguir los enlaces simbólicos, como si seespecificara "-L".".." se procesa quitando la componente del nombre de la ruta inmediatamenteanterior hasta una barra inclinada o el comienzo de DIR.Estado de Salida:Devuelve 0 si se cambia el directorio, y si $PWD está definido comocorrecto cuando se emplee -P; de otra forma es diferente a cero.
Manual with man
Another command is man
, which refers to the user manual.
terminal("man ls", max_lines_output=20)
LS(1) User Commands LS(1)NAMEls - list directory contentsSYNOPSISls [OPTION]... [FILE]...DESCRIPTIONList information about the FILEs (the current directory by default).Sort entries alphabetically if none of -cftuvSUX nor --sort is speci‐fied.Mandatory arguments to long options are mandatory for short optionstoo.-a, --alldo not ignore entries starting with .-A, --almost-all...Full documentation at: <https://www.gnu.org/software/coreutils/ls>or available locally via: info '(coreutils) ls invocation'GNU coreutils 8.30 September 2019 LS(1)
To exit, press q
, as man
uses less
as the manual viewer
Information with info
Another command is info
terminal("info ls", max_lines_output=20)
File: coreutils.info, Node: ls invocation, Next: dir invocation, Up: Directory listing10.1 ‘ls’: List directory contents==================================The ‘ls’ program lists information about files (of any type, includingdirectories). Options and file arguments can be intermixed arbitrarily,as usual.For non-option command-line arguments that are directories, bydefault ‘ls’ lists the contents of directories, not recursively, andomitting files with names beginning with ‘.’. For other non-optionarguments, by default ‘ls’ lists just the file name. If no non-optionargument is specified, ‘ls’ operates on the current directory, acting asif it had been invoked with a single argument of ‘.’.By default, the output is sorted alphabetically, according to thelocale settings in effect.(1) If standard output is a terminal, theoutput is in columns (sorted vertically) and control characters areoutput as question marks; otherwise, the output is listed one per line...‘--show-control-chars’Print nongraphic characters as-is in file names. This is thedefault unless the output is a terminal and the program is ‘ls’.
To exit, press q
, as info
uses less
as the information viewer.
Information about a command with whatis
Another command is whatis
terminal("whatis ls")
ls (1) - list directory contents
Wildcards
Wildcards are special characters that help us perform special searches. For example, if I want to search for all files ending in .txt
. Let's create a few files to see them.
terminal("touch file.txt dot.txt dot2.txt index.html datos1 datos123 Abc")
terminal("ls")
2021-02-11-Introduccion-a-Python.ipynbAbcdatos1datos123dot2.txtdot.txtfile.txtindex.html
All characters *
Let's now search for all .txt
files
!ls *.txt
dot2.txt dot.txt file.txt
Let's now search for all that start with the word datos
!ls datos*
datos1 datos123
Numbers ?
But what if we actually want to show all the files that start with the word datos
but are followed only by a number? We need to use a question mark ?
.
!ls datos?
datos1
If what we want is for it to have three numbers, then we have to put three question marks ???
!ls datos???
datos123
Uppercase [[:upper:]]
If we want it to search for files that start with uppercase letters
!ls [[:upper:]]*
Abc
Lowercase [[:lower:]]
For files that start with lowercase.
!ls [[:lower:]]*
datos1 datos123 dot2.txt dot.txt file.txt index.html
Classes
By using brackets, we can create classes; thus, if we want to search for files that start with the letters d
or f
followed by any character
!ls [df]*
datos1 datos123 dot2.txt dot.txt file.txt
Redirections: how the shell works
A command works as follows
It has a standard input
, which by default is the text we enter through the keyboard, a standard output
, which by default is the text that comes out on the console, and a standard error
which is also by default a text that comes out on the console, but has a different format.
Redirecting standard output
But with the >
character, we can modify the standard output
of a command. For example, if we want to list the files in the current directory with ls
, but we don't want the result to be printed on the screen, instead, we want it to be saved in a file, we would do the following ls > lista.txt
, this writes the list to lista.txt
, and if lista.txt
does not exist, it creates it.
!ls > lista.txt
We see that the file has been created and we see what is inside.
!ls > lista.txtterminal("ls")
2021-02-11-Introduccion-a-Python.ipynbAbcdatos1datos123dot2.txtdot.txtfile.txtindex.htmllista.txt
terminal("cat lista.txt")
2021-02-11-Introduccion-a-Python.ipynbAbcdatos1datos123dot2.txtdot.txtfile.txtindex.htmllista.txt
We see that lista.txt
appears within lista.txt
, that's because it first creates the file and then executes the command.
We do the same, but with the parent folder
!ls ../ > lista.txt
If we look inside lista.txt
again
!ls ../ > lista.txtterminal("cat lista.txt")
2021-02-11-Introduccion-a-Python.ipynb2021-04-23-Calculo-matricial-con-Numpy.ipynb2021-06-15-Manejo-de-datos-con-Pandas.ipynb2022-09-12 Introduccion a la terminal.ipynb2022-09-12 Introduccion a la terminal.txtcommand-line-cheat-sheet.pdfCSS.ipynbDocker.htmlDocker.ipynbExpresiones regulares.htmlExpresiones regulares.ipynbhtml_fileshtml.ipynbintroduccion_pythonmovies.csvmovies.datnotebooks_translatedprueba__pycache__ssh.ipynbtest.htmltest.ipynb
We see that the content is overwritten
If what we want is to concatenate the content, we should use >>
!ls > lista.txt
!ls > lista.txt!ls ../ >> lista.txt
!ls > lista.txt!ls ../ >> lista.txtterminal("cat lista.txt")
2021-02-11-Introduccion-a-Python.ipynbAbcdatos1datos123dot2.txtdot.txtfile.txtindex.htmllista.txt2021-02-11-Introduccion-a-Python.ipynb2021-04-23-Calculo-matricial-con-Numpy.ipynb2021-06-15-Manejo-de-datos-con-Pandas.ipynb2022-09-12 Introduccion a la terminal.ipynb2022-09-12 Introduccion a la terminal.txtcommand-line-cheat-sheet.pdfCSS.ipynbDocker.htmlDocker.ipynbExpresiones regulares.htmlExpresiones regulares.ipynbhtml_fileshtml.ipynbintroduccion_pythonmovies.csvmovies.datnotebooks_translatedprueba__pycache__ssh.ipynbtest.htmltest.ipynb
Now the information has been concatenated
This is very useful for creating log files
Redirecting standard error
If we perform an incorrect operation, we get an error. Let's see what happens when we redirect a command that gives an error.
!ls fjhdsalkfs > lista.txt
ls: no se puede acceder a 'fjhdsalkfs': No existe el archivo o el directorio
As we can see, it has given an error, but if we now look inside lista.txt
terminal("cat lista.txt")
We see that the file is empty, that's because we haven't redirected the standard error
to lista.txt
, but the standard output
. As we have seen in the image, there are two standard outputs in a command, the first one is the standard output
and the second one is the standard error
, so to redirect the standard error you have to indicate it with 2>
. Let's proceed this way now.
!ls kjhsfskjd 2> lista.txt
!ls kjhsfskjd 2> lista.txtterminal("cat lista.txt")
ls: no se puede acceder a 'kjhsfskjd': No existe el archivo o el directorio
As we can see, it has now been redirected
Redirecting standard output
and standard error
If we want to redirect both, we use the following
!ls kjhsfskjd > lista.txt 2>&1
Let's look inside lista.txt
!ls kjhsfskjd > lista.txt 2>&1terminal("cat lista.txt")
ls: no se puede acceder a 'kjhsfskjd': No existe el archivo o el directorio
If we now execute a command without errors
!ls . >> lista.txt 2>&1
Let's look inside lista.txt
(note, now we have concatenated)
!ls . >> lista.txt 2>&1terminal("cat lista.txt")
ls: no se puede acceder a 'kjhsfskjd': No existe el archivo o el directorio2021-02-11-Introduccion-a-Python.ipynbAbcdatos1datos123dot2.txtdot.txtfile.txtindex.htmllista.txt
As you can see, both standard error
and standard output
have been redirected to the same file.
Pipelines
We can create pipelines by making the standard output
of one command become the standard input
of another. For example, let's make the output of ls -lha
the input of grep
, which we will see later, but it is a command for searching.
!ls -lha | grep -i "txt"
-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt
As we can see, what we have done is pipe the output of ls
to grep
with which we have searched for any file with txt
in the name
Control Operators - Chaining Commands
Commands Sequentially
One way to chain commands sequentially is to separate them using ;
. This creates different threads for each task.
!ls; echo 'Hola'; cal
2021-02-11-Introduccion-a-Python.ipynb datos123 file.txtAbc dot2.txt index.htmldatos1 dot.txt lista.txtHolaDiciembre 2022do lu ma mi ju vi sá1 2 34 5 6 7 8 9 1011 12 13 14 15 16 1718 19 20 21 22 23 2425 26 27 28 29 30 31
As we can see, the ls
command was executed first, then Hello was printed thanks to the command echo "Hola"
, and finally a calendar was printed thanks to the command cal
.
Let's now do another example to see that they execute sequentially.
!echo "Before touch;"; ls -lha; touch secuential.txt; echo "After touch:"; ls -lha
Before touch;total 292Kdrwxrwxr-x 2 wallabot wallabot 4,0K dic 6 01:04 .drwxrwxr-x 7 wallabot wallabot 4,0K dic 6 00:24 ..-rw-rw-r-- 1 wallabot wallabot 280K dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txtAfter touch:total 292Kdrwxrwxr-x 2 wallabot wallabot 4,0K dic 6 01:07 .drwxrwxr-x 7 wallabot wallabot 4,0K dic 6 00:24 ..-rw-rw-r-- 1 wallabot wallabot 280K dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:07 secuential.txt
As you can see, in the first ls
, secuential.txt
does not appear, while in the second one it does. This means that the commands were executed sequentially, one after the other.
Parallel Commands
If what we want is for the commands to be executed in parallel, we must use the &
operator. This will create a new process for each command.
Let's look at the previous example
!rm secuential.txt
!rm secuential.txt!echo "Before touch;" & ls -lha & touch secuential.txt & echo "After touch:" & ls -lha
Before touch;After touch:total 292Kdrwxrwxr-x 2 wallabot wallabot 4,0K dic 6 01:08 .drwxrwxr-x 7 wallabot wallabot 4,0K dic 6 00:24 ..-rw-rw-r-- 1 wallabot wallabot 280K dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txt
Now you can see that they have not been executed sequentially, since the echo
s have been executed first, which will take the least time, and then the rest.
Conditional Commands
And
Using the &&
operator, a command will execute when the previous one has successfully run
!rm secuential.txt
!rm secuential.txt!echo "Before touch;" && ls -lha && touch secuential.txt && echo "After touch:" && ls -lha
Before touch;total 292Kdrwxrwxr-x 2 wallabot wallabot 4,0K dic 6 01:08 .drwxrwxr-x 7 wallabot wallabot 4,0K dic 6 00:24 ..-rw-rw-r-- 1 wallabot wallabot 280K dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txtAfter touch:total 292Kdrwxrwxr-x 2 wallabot wallabot 4,0K dic 6 01:08 .drwxrwxr-x 7 wallabot wallabot 4,0K dic 6 00:24 ..-rw-rw-r-- 1 wallabot wallabot 280K dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txt
Here we can see how it has been executed one after another, that is, a command does not start until the previous one ends
But then, what's the difference between ;
and &&
?
In the first case, the sequential ;
, one command is executed first and then the other, but for a command to be executed, it doesn't matter if the previous one was executed successfully.
!rm prueba ; ls -lha
rm: no se puede borrar 'prueba': No existe el archivo o el directoriototal 292Kdrwxrwxr-x 2 wallabot wallabot 4,0K dic 6 01:08 .drwxrwxr-x 7 wallabot wallabot 4,0K dic 6 00:24 ..-rw-rw-r-- 1 wallabot wallabot 280K dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txt
As you can see, first rm prueba
is executed, an error occurs, and ls -lha prueba
is still executed.
In the conditional manner &&
, if a command does not execute successfully, the next one will not be executed.
!rm prueba && ls -lha
rm: no se puede borrar 'prueba': No existe el archivo o el directorio
As you can see ls -lha prueba
does not execute because rm prueba
has given an error
Or
Unlike &&
, the 'or' will execute all processes regardless of their result. The ||
operator should be used.
!rm prueba || ls -lha
rm: no se puede borrar 'prueba': No existe el archivo o el directoriototal 292Kdrwxrwxr-x 2 wallabot wallabot 4,0K dic 6 01:08 .drwxrwxr-x 7 wallabot wallabot 4,0K dic 6 00:24 ..-rw-rw-r-- 1 wallabot wallabot 280K dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txt
The difference between this and ;
is that ||
(or) does not create a new thread for each command
How Permissions are Managed
When listing the files in a directory with the -l
(long) flag, some symbols appear next to each file.
!mkdir subdirectorio
!mkdir subdirectorio!ls -l
total 288-rw-rw-r-- 1 wallabot wallabot 285898 dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txtdrwxrwxr-x 2 wallabot wallabot 4096 dic 6 01:10 subdirectorio
This gives us information about each file
First, let's see what types of files there are. * -: Regular file* d: Directory* l: Symbolic link* b: Special block file. These are files that manage data block information, such as a USB
Later we will see the types of mode:
<table border="1">
``````markdown
<header>
```<tr><th scope="col" colspan="3">Owner</th><th scope="col" colspan="3">Group</th><th scope="col" colspan="3">Mundo</th>```markdown
</tr>
``` </header><body> <tr><th scope="row" colspan="3">rwx</th><th scope="row" colspan="3">r-x</th><th scope="row" colspan="3">r-x</th> </tr> <tr> <th scope="row">1</th><th scope="row">1</th> <th scope="row">1</th><th scope="row">1</th><th scope="row">0</th> <th scope="row">1</th> <th scope="row">1</th><th scope="row">0</th><th scope="row">1</th> </tr> <tr> <th scope="row" colspan="3">7</th> <th scope="row" colspan="3">5</th> <th scope="row" colspan="3">5</th> </tr><body></table>
* r: read* w: write * x: execute
Symbolic mode:* u: User-only* g: Group only* o: Only for others (world)* a: For all
Modifying Permissions in the Terminal
We create a new file
terminal("cd subdirectorio")
terminal("cd subdirectorio")!echo "hola mundo" > mitexto.txt
terminal("cd subdirectorio")!echo "hola mundo" > mitexto.txt!cat mitexto.txt
hola mundo
Let's see the permissions it has.
!ls -l
total 4-rw-rw-r-- 1 wallabot wallabot 11 dic 6 01:10 mitexto.txt
As we can see, it has read and write permissions for my user and the group, and only read permissions for the rest (world)
Changing Permissions with chmod
(change mode)
To change the permissions of a file we use the chmod
(change mode) command, where we need to set the user's permissions first in octal, then the group's, and lastly the others'.
!chmod 755 mitexto.txt
!chmod 755 mitexto.txt!ls -l
total 4-rwxr-xr-x 1 wallabot wallabot 11 dic 6 01:10 mitexto.txt
We see that now my user has read, write, and execute permissions, while the group and the rest of the world have read and execute permissions.
We are going to remove the read permissions only for my user. To change only the permissions for a user, we use the symbolic identifier, a +
if we want to add permissions or a -
if we want to remove them or a =
if we want to reset them followed by the type of permission
!chmod u-r mitexto.txt
!chmod u-r mitexto.txt!ls -l
total 4--wxr-xr-x 1 wallabot wallabot 11 dic 6 01:10 mitexto.txt
!cat mitexto.txt
cat: mitexto.txt: Permiso denegado
As we can see, by removing read permissions for my user, we cannot read the file.
We will grant the read permission again
!chmod u+r mitexto.txt
!chmod u+r mitexto.txt!ls -l
total 4-rwxr-xr-x 1 wallabot wallabot 11 dic 6 01:10 mitexto.txt
!cat mitexto.txt
hola mundo
If we want to add or remove permissions for more than one user, we do so by separating each permission with a ,
!chmod u-x,go=w mitexto.txt
!chmod u-x,go=w mitexto.txt!ls -l
total 4-rw--w--w- 1 wallabot wallabot 11 dic 6 01:10 mitexto.txt
As can be seen, execution permission has been removed for the user and write-only permission has been set for the group and the rest of the world.
User Identification with whoami
To find out who we are, we can use the whoami
(who am I) command.
!whoami
wallabot
User Information with id
Another way, which also provides more information, is the id
command.
!id
uid=1000(wallabot) gid=1000(wallabot) grupos=1000(wallabot),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),120(lpadmin),131(lxd),132(sambashare),998(docker)
This command tells us that our user ID is 1000, the group ID is 1000, and that we belong to the groups wallabot, adm, cdrom, sudo, dip, plugdev, lpadmin, lxd, sambashare, and docker
Change of user with the su
(switch user) command
If we want to switch users, we use the su
(switch user) command. For certain users, we need to use sudo
(superuser do)
!sudo su root
root@wallabot:/home/wallabot/Documentos/web/portafolio/posts/prueba/subdirectorio#
As we can see, the prompt
changes and now indicates that we are the user root
.
Let's go to the home folder
!cd
root@wallabot:~#
But in Linux there is a home folder for each user, we can see this if we run the command pwd
!pwd
/root
I am going to create a file in the folder where I previously created the mitexto.txt file.
!touch /home/wallabot/Documentos/web/portafolio/posts/prueba/subdirectorio/rootfile.txt
I change back to my user
!su wallabot
wallabot@wallabot:
And I go to the directory where the files I have created are located.
!cd /home/wallabot/Documentos/web/portafolio/posts/prueba/subdirectorio
We see the files that are there and their permissions
!cd /home/wallabot/Documentos/web/portafolio/posts/prueba/subdirectorio!ls -l
total 4-rw--w--w- 1 wallabot wallabot 11 dic 6 01:10 mitexto.txt-rw-r--r-- 1 root root 0 dic 6 01:22 rootfile.txt
As we can see, the owner and group of the file rootfile.txt is the user root
If I, now that I am the user wallabot, try to delete the file rootfile.txt
!rm rootfile.txt
rm: ¿borrar el fichero regular vacío 'rootfile.txt' protegido contra escritura? (s/n)
As we can see, it asks us if we want to delete it, as it belongs to another user.
Change a User's Password
If I want to modify the password of the currently active user, I use the passwd
(password) command.
First, I check which user I am
!whoami
wallabot
And now we try to change the password
!passwd
$ passwdCambiando la contraseña de wallabot.Contraseña actual de :Nueva contraseña:Vuelva a escribir la nueva contraseña
As we can see, it asks for the current password in order to change it.
Symbolic Links
We can create symbolic links to a specific path using the ln
(link) command followed by the -s
(symbolic) flag, the directory, and the name of the link.
!ln -s /home/wallabot/Documentos/web web
If we now list the files
!ln -s /home/wallabot/Documentos/web web!ls -l
total 4-rw--w--w- 1 wallabot wallabot 11 dic 6 01:10 mitexto.txt-rw-r--r-- 1 root root 0 dic 6 01:22 rootfile.txtlrwxrwxrwx 1 wallabot wallabot 29 dic 6 01:28 web -> /home/wallabot/Documentos/web
We see the symbolic link web
pointing to /home/wallabot/Documentos/web:
I can now go to web
terminal("cd web")
terminal("cd web")!pwd
/home/wallabot/Documentos/web
Set environment variables
Viewing Environment Variables with printenv
With the printenv
command, we can see all the environment variables
!printenv
GJS_DEBUG_TOPICS=JS ERROR;JS LOGVSCODE_CWD=/home/wallabotLESSOPEN=| /usr/bin/lesspipe %sCONDA_PROMPT_MODIFIER=(base)PYTHONIOENCODING=utf-8USER=wallabotVSCODE_NLS_CONFIG={"locale":"es","availableLanguages":{"*":"es"},"_languagePackId":"b07c40c9acb9e1d7b3ca14b06f814803.es","_translationsConfigFile":"/home/wallabot/.config/Code/clp/b07c40c9acb9e1d7b3ca14b06f814803.es/tcf.json","_cacheRoot":"/home/wallabot/.config/Code/clp/b07c40c9acb9e1d7b3ca14b06f814803.es","_resolvedLanguagePackCoreLocation":"/home/wallabot/.config/Code/clp/b07c40c9acb9e1d7b3ca14b06f814803.es/6261075646f055b99068d3688932416f2346dd3b","_corruptedFile":"/home/wallabot/.config/Code/clp/b07c40c9acb9e1d7b3ca14b06f814803.es/corrupted.info","_languagePackSupport":true}VSCODE_HANDLES_UNCAUGHT_ERRORS=trueMPLBACKEND=module://ipykernel.pylab.backend_inlineSSH_AGENT_PID=1373XDG_SESSION_TYPE=x11SHLVL=0HOME=/home/wallabotCHROME_DESKTOP=code-url-handler.desktopCONDA_SHLVL=1DESKTOP_SESSION=ubuntuGIO_LAUNCHED_DESKTOP_FILE=/usr/share/applications/code.desktopVSCODE_IPC_HOOK=/run/user/1000/vscode-26527400-1.73.1-main.sockPYTHONUNBUFFERED=1GTK_MODULES=gail:atk-bridgeGNOME_SHELL_SESSION_MODE=ubuntuAPPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL=truePAGER=catMANAGERPID=1153DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/busGIO_LAUNCHED_DESKTOP_FILE_PID=3897_CE_M=IM_CONFIG_PHASE=1LOGNAME=wallabot_=/home/wallabot/anaconda3/bin/pythonJOURNAL_STREAM=8:52662XDG_SESSION_CLASS=userUSERNAME=wallabotTERM=xterm-colorGNOME_DESKTOP_SESSION_ID=this-is-deprecated_CE_CONDA=WINDOWPATH=2PATH=/home/wallabot/anaconda3/bin:/home/wallabot/anaconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/binSESSION_MANAGER=local/wallabot:@/tmp/.ICE-unix/1410,unix/wallabot:/tmp/.ICE-unix/1410INVOCATION_ID=73bba2d15f2e492fa6c16538996a2556VSCODE_AMD_ENTRYPOINT=vs/workbench/api/node/extensionHostProcessXDG_RUNTIME_DIR=/run/user/1000XDG_MENU_PREFIX=gnome-GDK_BACKEND=x11DISPLAY=:0LANG=es_ES.UTF-8XDG_CURRENT_DESKTOP=UnityXAUTHORITY=/run/user/1000/gdm/XauthorityXDG_SESSION_DESKTOP=ubuntuXMODIFIERS=@im=ibusLS_COLORS=SSH_AUTH_SOCK=/run/user/1000/keyring/sshORIGINAL_XDG_CURRENT_DESKTOP=ubuntu:GNOMECONDA_PYTHON_EXE=/home/wallabot/anaconda3/bin/pythonSHELL=/bin/bashELECTRON_RUN_AS_NODE=1QT_ACCESSIBILITY=1GDMSESSION=ubuntuLESSCLOSE=/usr/bin/lesspipe %s %sCONDA_DEFAULT_ENV=basePYDEVD_IPYTHON_COMPATIBLE_DEBUGGING=1GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:0:1GJS_DEBUG_OUTPUT=stderrQT_IM_MODULE=ibusGIT_PAGER=catPWD=/home/wallabot/Documentos/webCLICOLOR=1XDG_DATA_DIRS=/usr/share/ubuntu:/usr/local/share/:/usr/share/:/var/lib/snapd/desktopXDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdgVSCODE_CODE_CACHE_PATH=/home/wallabot/.config/Code/CachedData/6261075646f055b99068d3688932416f2346dd3bCONDA_EXE=/home/wallabot/anaconda3/bin/condaCONDA_PREFIX=/home/wallabot/anaconda3VSCODE_PID=3897
View an environment variable with the echo
command
To see a specific environment variable, we can do it using the echo
command followed by the $
symbol and the name of the variable
!echo $HOME
/home/wallabot
Modify an environment variable for a terminal session
We can modify an environment variable for the active terminal session, for example, let's add a new path to the PATH
variable. First, let's see what's in it
!echo $PATH
/home/wallabot/anaconda3/bin:/home/wallabot/anaconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
Now we add a new directory
!PATH=$PATH:"subdirectorio
We return to see what's inside PATH
!echo $PATH
/home/wallabot/anaconda3/bin:/home/wallabot/anaconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:subdirectorio
We see that the subdirectory
directory has been added.
The problem with this method is that when we open a new terminal this change in PATH
will not be maintained.
Modify an environment variable for all terminal sessions
We go to the home folder
terminal("cd /home/wallabot")
Here in the home, we list all files with the -a
(all) flag
terminal("cd /home/wallabot")!ls -a
. .eclipse .pki.. Escritorio Plantillas.afirma .gitconfig .platformioanaconda3 .gnupg .profile.audacity-data Imágenes .psensor.bash_history .ipython Público.bash_logout .java .python_history.bashrc .jupyter snap.cache .lesshst .ssh.conda Lightworks .sudo_as_admin_successful.config .Lightworks.thereCanBeOnlyOne .thunderbird.cortex-debug .local Vídeos.cyberghost logiops .vnc.dbus .MCTranscodingSDK .vscodeDescargas .mozilla .wget-hsts.docker MúsicaDocumentos .nv
We see that there is a file called .bashrc
, this file is the file that contains the configuration of our bash
terminal("cat .bashrc", max_lines_output=3)
# ~/.bashrc: executed by bash(1) for non-login shells.# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)# for examples...fiunset __conda_setup# <<< conda initialize <<<
This file configures the terminal each time a new one is opened, so if we edit the PATH
variable in it, this change will persist for all new terminal windows we open.
To modify the PATH
variable within the configuration file, we need to add the following line to the file
PATH=$PATH:"subdirectory"```
Create aliases for all sessions
We already saw how to create command aliases, but it also happened that they were lost every time we closed a terminal session. To prevent this, we also add them to the .bashrc
configuration file. For example, in my case, I have added the following lines.
alias ll='ls -l'alias la='ls -a'
bash
alias lh='ls -h'
alias
Search Commands
Searching for Binaries with which
The first search command we will see is which
which allows us to find the path of the binaries
!which python
/home/wallabot/anaconda3/bin/python
However, if we look for something that is not in any of the PATH routes, which
will not be able to tell us the path.
!which cd
File Search with find
To search for a file with find, we need to indicate from which path we want to search for the file, followed by the -name
flag and the name of the file we want to search for.
!which cd!find ~ -name "2021-02-11-Introduccion-a-Python.ipynb"
/home/wallabot/Documentos/web/portafolio/posts/prueba/2021-02-11-Introduccion-a-Python.ipynb/home/wallabot/Documentos/web/portafolio/posts/2021-02-11-Introduccion-a-Python.ipynb
As we can see, it is in its directory plus the copy that I have created in this notebook and saved in the prueba
folder
One very powerful thing about find
is that we can use wildcards
, for example, if I want to search for all text files in my web
folder.
!find ~/Documentos/web/ -name *.txt
/home/wallabot/Documentos/web/portafolio/posts/2022-09-12 Introduccion a la terminal.txt/home/wallabot/Documentos/web/portafolio/posts/prueba/lista.txt/home/wallabot/Documentos/web/portafolio/posts/prueba/dot.txt/home/wallabot/Documentos/web/portafolio/posts/prueba/dot2.txt/home/wallabot/Documentos/web/portafolio/posts/prueba/secuential.txt/home/wallabot/Documentos/web/portafolio/posts/prueba/subdirectorio/rootfile.txt/home/wallabot/Documentos/web/portafolio/posts/prueba/subdirectorio/mitexto.txt/home/wallabot/Documentos/web/portafolio/posts/prueba/file.txt/home/wallabot/Documentos/web/wordpress_api_rest/page.txt
If we do not want it to distinguish between uppercase and lowercase, we must use the -iname
flag. For example, if we search for all files that contain the text FILE
, but using the -iname
flag.
!find ~/Documentos/web/ -iname *FILE*
/home/wallabot/Documentos/web/portafolio/posts/html_files/home/wallabot/Documentos/web/portafolio/posts/prueba/subdirectorio/rootfile.txt/home/wallabot/Documentos/web/portafolio/posts/prueba/file.txt
We see that all the results contain file
and not FILE
, that is, it has not distinguished between uppercase and lowercase
We can specify the file type with the -type
flag. It only accepts two types f
for files and d
for directories.
!find ~/Documentos/nerf -name image*
/home/wallabot/Documentos/nerf/instant-ngp/configs/image/home/wallabot/Documentos/nerf/instant-ngp/dependencies/tiny-cuda-nn/benchmarks/image/home/wallabot/Documentos/nerf/instant-ngp/dependencies/tiny-cuda-nn/dependencies/cutlass/media/images/home/wallabot/Documentos/nerf/instant-ngp/dependencies/tiny-cuda-nn/dependencies/fmt/doc/bootstrap/mixins/image.less/home/wallabot/Documentos/nerf/instant-ngp/dependencies/tiny-cuda-nn/data/images/home/wallabot/Documentos/nerf/instant-ngp/dependencies/dlss/NVIDIAImageScaling/samples/media/images/home/wallabot/Documentos/nerf/instant-ngp/data/nerf/fox/images/home/wallabot/Documentos/nerf/instant-ngp/data/image
!find ~/Documentos/nerf -name image* -type d
/home/wallabot/Documentos/nerf/instant-ngp/configs/image/home/wallabot/Documentos/nerf/instant-ngp/dependencies/tiny-cuda-nn/benchmarks/image/home/wallabot/Documentos/nerf/instant-ngp/dependencies/tiny-cuda-nn/dependencies/cutlass/media/images/home/wallabot/Documentos/nerf/instant-ngp/dependencies/tiny-cuda-nn/data/images/home/wallabot/Documentos/nerf/instant-ngp/dependencies/dlss/NVIDIAImageScaling/samples/media/images/home/wallabot/Documentos/nerf/instant-ngp/data/nerf/fox/images/home/wallabot/Documentos/nerf/instant-ngp/data/image
!find ~/Documentos/nerf -name image* -type f
/home/wallabot/Documentos/nerf/instant-ngp/dependencies/tiny-cuda-nn/dependencies/fmt/doc/bootstrap/mixins/image.less
If we want to filter by file size we can use the -size
flag, for example, if we want to search for all files larger than 200 MB
!find ~/Documentos/ -type f -size +200M
/home/wallabot/Documentos/kaggle/hubmap/models/13_efficientnet-b7_final_model.pth/home/wallabot/Documentos/kaggle/hubmap/models/12_efficientnet-b7_final_model.pth/home/wallabot/Documentos/kaggle/hubmap/models/14_resnet152_final_model.pth/home/wallabot/Documentos/kaggle/hubmap/models/14_resnet152_best_model.pth/home/wallabot/Documentos/kaggle/hubmap/models/12_efficientnet-b7_early_stopping.pth/home/wallabot/Documentos/kaggle/hubmap/models/efficientnet-b7-dcc49843.pth/home/wallabot/Documentos/kaggle/hubmap/models/13_efficientnet-b7_early_stopping.pth/home/wallabot/Documentos/kaggle/hubmap/models/14_resnet152_early_stopping.pth/home/wallabot/Documentos/kaggle/hubmap/models/12_efficientnet-b7_best_model.pth/home/wallabot/Documentos/kaggle/hubmap/models/13_efficientnet-b7_best_model.pth
If we want to perform operations after the search, we use the -exec
flag
For example, I am going to search for all folders named subdirectorio
!find ~/ -name subdirectorio -type d
/home/wallabot/Documentos/web/portafolio/posts/prueba/subdirectorio
I can make them delete with the -exec
flag
!find ~/ -name subdirectorio -type d -exec rm -r {} ;
rm: ¿borrar el fichero regular vacío '/home/wallabot/Documentos/web/portafolio/posts/prueba/subdirectorio/rootfile.txt' protegido contra escritura? (s/n) sfind: ‘/home/wallabot/Documentos/web/portafolio/posts/prueba/subdirectorio’: No existe el archivo o el directorio
!find ~/ -name subdirectorio -type d
Finally, if we use the !
character, we will be indicating that it should find everything that does not match what we have specified.
!find ~/ -name subdirectorio -type d!find ~/Documentos/web/portafolio/posts/prueba ! -name *.txt
/home/wallabot/Documentos/web/portafolio/posts/prueba/home/wallabot/Documentos/web/portafolio/posts/prueba/index.html/home/wallabot/Documentos/web/portafolio/posts/prueba/Abc/home/wallabot/Documentos/web/portafolio/posts/prueba/datos1/home/wallabot/Documentos/web/portafolio/posts/prueba/2021-02-11-Introduccion-a-Python.ipynb/home/wallabot/Documentos/web/portafolio/posts/prueba/datos123
As we can see, it has found everything that is not a .txt
grep
Search Command
grep
is a very powerful search command, that's why we dedicate a section to it alone. The grep
command uses regular expressions, so if you want to learn about them, I leave you a link to a post where I explain them.
Let's start to see the power of this command, let's search for all the times the text MaximoFN
appears within the file 2021-02-11-Introduccion-a-Python.ipynb
terminal("cd /home/wallabot/Documentos/web/portafolio/posts/prueba")
terminal("cd /home/wallabot/Documentos/web/portafolio/posts/prueba")terminal("grep MaximoFN 2021-02-11-Introduccion-a-Python.ipynb", max_lines_output=20)
"a = 'MaximoFN' ","'MaximoFN'""string = "MaximoFN" ","'MaximoFN'""string = 'MaximoFN' ","'MaximoFN'""Este es el blog de "MaximoFN" ""print("Este es el blog de \"MaximoFN\"")""Este es el blog de 'MaximoFN' ""print('Este es el blog de \'MaximoFN\'')""Este es el blog de \MaximoFN\\n""print('Este es el blog de \\MaximoFN\\\')""MaximoFN ""print('Este es el blog de \nMaximoFN')""Este es el blog de MaximoFN ""print('Esto no se imprimirá \rEste es el blog de MaximoFN')""Este es el blog de MaximoFN ""print('Este es el blog de \tMaximoFN')""Este es el blog deMaximoFN ""print('Este es el blog de \bMaximoFN')"..."funcion2_del_modulo('MaximoFN')""MaximoFN "," print('MaximoFN') "," variable = 'MaximoFN' ",
However, if we perform the same search for the text maximofn
!grep maximofn 2021-02-11-Introduccion-a-Python.ipynb
No results appear, this is because grep
is case sensitive
, that is, it searches the text exactly as you have entered it, differentiating between uppercase and lowercase. If we don't want this, we need to introduce the -i
flag.
!grep maximofn 2021-02-11-Introduccion-a-Python.ipynbterminal("grep -i MaximoFN 2021-02-11-Introduccion-a-Python.ipynb", max_lines_output=20)
"a = 'MaximoFN' ","'MaximoFN'""string = "MaximoFN" ","'MaximoFN'""string = 'MaximoFN' ","'MaximoFN'""Este es el blog de "MaximoFN" ""print("Este es el blog de \"MaximoFN\"")""Este es el blog de 'MaximoFN' ""print('Este es el blog de \'MaximoFN\'')""Este es el blog de \MaximoFN\\n""print('Este es el blog de \\MaximoFN\\\')""MaximoFN ""print('Este es el blog de \nMaximoFN')""Este es el blog de MaximoFN ""print('Esto no se imprimirá \rEste es el blog de MaximoFN')""Este es el blog de MaximoFN ""print('Este es el blog de \tMaximoFN')""Este es el blog deMaximoFN ""print('Este es el blog de \bMaximoFN')"..."funcion2_del_modulo('MaximoFN')""MaximoFN "," print('MaximoFN') "," variable = 'MaximoFN' ",
If what we want is for it to return the number of times it appears, we use the -c
flag
!grep -c MaximoFN 2021-02-11-Introduccion-a-Python.ipynb
105
If we don't care if it appears in uppercase or lowercase, we can add the -i
flag again, but there's no need to separate it from the -c
flag; they can be introduced together
!grep -ci MaximoFN 2021-02-11-Introduccion-a-Python.ipynb
105
If now we want all the times in which the word MáximoFN
does not appear, we introduce the -v
flag
!grep -cv MaximoFN 2021-02-11-Introduccion-a-Python.ipynb
11573
Network Utilities
Network Interface Information with ifconfig
The first command will be ifconfig
which shows us information about our network interfaces.
!ifconfig
br-470e52ae2708: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500inet 172.18.0.1 netmask 255.255.0.0 broadcast 172.18.255.255ether 02:42:ac:d0:b9:eb txqueuelen 0 (Ethernet)RX packets 0 bytes 0 (0.0 B)RX errors 0 dropped 0 overruns 0 frame 0TX packets 0 bytes 0 (0.0 B)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255ether 02:42:5d:15:1c:e9 txqueuelen 0 (Ethernet)RX packets 0 bytes 0 (0.0 B)RX errors 0 dropped 0 overruns 0 frame 0TX packets 0 bytes 0 (0.0 B)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0enp6s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500inet 192.168.1.144 netmask 255.255.255.0 broadcast 192.168.1.255inet6 fe80::7dc2:6944:3fbe:c18e prefixlen 64 scopeid 0x20<link>ether 24:4b:fe:5c:f6:59 txqueuelen 1000 (Ethernet)RX packets 144369 bytes 123807349 (123.8 MB)RX errors 0 dropped 2056 overruns 0 frame 0TX packets 100672 bytes 55678042 (55.6 MB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536inet 127.0.0.1 netmask 255.0.0.0inet6 ::1 prefixlen 128 scopeid 0x10<host>loop txqueuelen 1000 (Bucle local)RX packets 10748 bytes 1832545 (1.8 MB)RX errors 0 dropped 0 overruns 0 frame 0TX packets 10748 bytes 1832545 (1.8 MB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0wlp5s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500ether 4c:77:cb:1d:66:cc txqueuelen 1000 (Ethernet)RX packets 0 bytes 0 (0.0 B)RX errors 0 dropped 0 overruns 0 frame 0TX packets 0 bytes 0 (0.0 B)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
As we can see, we have information about all the network interfaces of my computer, but if I want to know only one, it is specified by adding its name.
!ifconfig enp6s0
enp6s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500inet 192.168.1.144 netmask 255.255.255.0 broadcast 192.168.1.255inet6 fe80::7dc2:6944:3fbe:c18e prefixlen 64 scopeid 0x20<link>ether 24:4b:fe:5c:f6:59 txqueuelen 1000 (Ethernet)RX packets 144467 bytes 123842258 (123.8 MB)RX errors 0 dropped 2060 overruns 0 frame 0TX packets 100786 bytes 55749109 (55.7 MB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Network Interface Information with ip
Another way to obtain information about our network interfaces is by using the ip
command; adding a
gives us information about all interfaces.
!ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope hostvalid_lft forever preferred_lft forever2: enp6s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000link/ether 24:4b:fe:5c:f6:59 brd ff:ff:ff:ff:ff:ffinet 192.168.1.144/24 brd 192.168.1.255 scope global dynamic noprefixroute enp6s0valid_lft 80218sec preferred_lft 80218secinet6 fe80::7dc2:6944:3fbe:c18e/64 scope link noprefixroutevalid_lft forever preferred_lft forever3: wlp5s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000link/ether 4c:77:cb:1d:66:cc brd ff:ff:ff:ff:ff:ff4: br-470e52ae2708: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group defaultlink/ether 02:42:ac:d0:b9:eb brd ff:ff:ff:ff:ff:ffinet 172.18.0.1/16 brd 172.18.255.255 scope global br-470e52ae2708valid_lft forever preferred_lft forever5: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group defaultlink/ether 02:42:5d:15:1c:e9 brd ff:ff:ff:ff:ff:ffinet 172.17.0.1/16 brd 172.17.255.255 scope global docker0valid_lft forever preferred_lft forever
Communication Test with ping
Another useful command is ping
, which can help us see if we have a connection to a specific IP
. For example, Google's IP
is 142.250.200.78
, so we do a ping
to see if it responds. The ping
command in Linux pings continuously, so it never ends until we stop it. To prevent this, we add the -c
flag and the number of attempts.
!ping 142.250.200.132 -c 4
PING 142.250.200.132 (142.250.200.132) 56(84) bytes of data.64 bytes from 142.250.200.132: icmp_seq=1 ttl=117 time=3.46 ms64 bytes from 142.250.200.132: icmp_seq=2 ttl=117 time=3.77 ms64 bytes from 142.250.200.132: icmp_seq=3 ttl=117 time=2.81 ms64 bytes from 142.250.200.132: icmp_seq=4 ttl=117 time=2.86 ms--- 142.250.200.132 ping statistics ---4 packets transmitted, 4 received, 0% packet loss, time 3004msrtt min/avg/max/mdev = 2.812/3.227/3.773/0.405 ms
The same would have happened if we had done it directly on google.com
!ping www.google.com -c 4
PING www.google.com (142.250.200.132) 56(84) bytes of data.64 bytes from mad41s14-in-f4.1e100.net (142.250.200.132): icmp_seq=1 ttl=117 time=2.74 ms64 bytes from mad41s14-in-f4.1e100.net (142.250.200.132): icmp_seq=2 ttl=117 time=3.96 ms64 bytes from mad41s14-in-f4.1e100.net (142.250.200.132): icmp_seq=3 ttl=117 time=3.56 ms64 bytes from mad41s14-in-f4.1e100.net (142.250.200.132): icmp_seq=4 ttl=117 time=2.87 ms--- www.google.com ping statistics ---4 packets transmitted, 4 received, 0% packet loss, time 3003msrtt min/avg/max/mdev = 2.741/3.283/3.962/0.499 ms
Download Source Files with curl
We can obtain a text file from a given address using the curl
command, for example, we can download Google's html.
!curl https://www.google.com
<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="es"><head><meta content="Google.es permite acceder a la informaci�n mundial en castellano, catal�n, gallego, euskara e ingl�s." name="description"><meta content="noodp" name="robots"><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"><meta content="/images/branding/googleg/1x/googleg_standard_color_128dp.png" itemprop="image"><title>Google</title><script nonce="zXcc4tMJWBRoE7q_o_Z2fQ">(function(){window.google={kEI:'M5GOY6PeLr-jkdUP1pir0AE',kEXPI:'0,1359409,6059,206,4804,2316,383,246,5,5367,1123753,1197713,688,380089,16115,28684,22430,1362,12312,17587,4998,13228,3847,10622,22741,5081,1593,1279,2742,149,1103,840,1983,214,4100,3514,606,2023,2297,14670,3227,2845,7,4773,28997,1850,15757,3,346,230,6459,149,13975,4,1528,2304,7039,27731,7357,13658,4437,16786,5815,2542,4094,4052,3,3541,1,14262,27892,2,14022,6248,19490,5680,1021,2380,28741,4569,6255,23421,1252,5835,14967,4333,7484,11406,15676,8155,7381,15970,873,14804,1,4828,7,1922,5784,12208,10330,587,12192,4832,26504,5796,3,14433,3890,751,13384,1499,3,679,1622,1779,1886,338,1627,1119,6,8909,80,243,458,3438,1763,722,1020,813,91,1133,10,280,2306,44,77,1420,3,562,402,314,275,2095,440,399,138,384,1033,334,2667,2,723,444,79,403,501,929,3,785,2,240,78,2022,284,196,732,175,342,244,617,335,1,841,1275,14,979,57,857,446,2,1900,838,251,227,50,21,8,3,442,57,40,936,697,773,95,121,643,1502,163,355,702,195,1,452,50,334,687,109,1,19,109,134,546,80,5,36,124,68,135,131,415,47,27,266,563,48,231,742,15,527,2,6,495,1,495,5,62,1627,441,262,5,3,648,3,6,4,13,39,538,792,337,9,115,98,180,148,308,401,1240,2,726,243,2044,5286450,84,19,32,115,11,70,5995534,2803414,3311,141,795,19735,1,1,346,1755,1004,41,342,1,189,14,1,10,8,1,5,4,2,1,3,2,2,1,3,1,3,1,4,3,1,3,2,2,23947076,511,21,11,4041599,1964,1007,2087,13579,3102,303,5595,11,3835,3637,2623,9,136,1524825',kBL:'p9Xv'};google.sn='webhp';google.kHL='es';})();(function(){var f=this||self;var h,k=[];function l(a){for(var b;a&&(!a.getAttribute||!(b=a.getAttribute("eid")));)a=a.parentNode;return b||h}function m(a){for(var b=null;a&&(!a.getAttribute||!(b=a.getAttribute("leid")));)a=a.parentNode;return b}function n(a,b,c,d,g){var e="";c||-1!==b.search("&ei=")||(e="&ei="+l(d),-1===b.search("&lei=")&&(d=m(d))&&(e+="&lei="+d));d="";!c&&f._cshid&&-1===b.search("&cshid=")&&"slh"!==a&&(d="&cshid="+f._cshid);c=c||"/"+(g||"gen_204")+"?atyp=i&ct="+a+"&cad="+b+e+"&zx="+Date.now()+d;/^http:/i.test(c)&&"https:"===window.location.protocol&&(google.ml&&google.ml(Error("a"),!1,{src:c,glmm:1}),c="");return c};h=google.kEI;google.getEI=l;google.getLEI=m;google.ml=function(){return null};google.log=function(a,b,c,d,g){if(c=n(a,b,c,d,g)){a=new Image;var e=k.length;k[e]=a;a.onerror=a.onload=a.onabort=function(){delete k[e]};a.src=c}};google.logUrl=n;}).call(this);(function(){google.y={};google.sy=[];google.x=function(a,b){if(a)var c=a.id;else{do c=Math.random();while(google.y[c])}google.y[c]=[a,b];return!1};google.sx=function(a){google.sy.push(a)};google.lm=[];google.plm=function(a){google.lm.push.apply(google.lm,a)};google.lq=[];google.load=function(a,b,c){google.lq.push([[a],b,c])};google.loadAll=function(a,b){google.lq.push([a,b])};google.bx=!1;google.lx=function(){};}).call(this);google.f={};(function(){document.documentElement.addEventListener("submit",function(b){var a;if(a=b.target){var c=a.getAttribute("data-submitfalse");a="1"===c||"q"===c&&!a.elements.q.value?!0:!1}else a=!1;a&&(b.preventDefault(),b.stopPropagation())},!0);document.documentElement.addEventListener("click",function(b){var a;a:{for(a=b.target;a&&a!==document.documentElement;a=a.parentElement)if("A"===a.tagName){a="1"===a.getAttribute("data-nohref");break a}a=!1}a&&b.preventDefault()},!0);}).call(this);</script><style>#gbar,#guser{font-size:13px;padding-top:1px !important;}#gbar{height:22px}#guser{padding-bottom:7px !important;text-align:right}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}@media all{.gb1{height:22px;margin-right:.5em;vertical-align:top}#gbar{float:left}}a.gb1,a.gb4{text-decoration:underline !important}a.gb1,a.gb4{color:#00c !important}.gbi .gb4{color:#dd8e27 !important}.gbf .gb4{color:#900 !important}</style><style>body,td,a,p,.h{font-family:arial,sans-serif}body{margin:0;overflow-y:scroll}#gog{padding:3px 8px 0}td{line-height:.8em}.gac_m td{line-height:17px}form{margin-bottom:20px}.h{color:#1558d6}em{font-weight:bold;font-style:normal}.lst{height:25px;width:496px}.gsfi,.lst{font:18px arial,sans-serif}.gsfs{font:17px arial,sans-serif}.ds{display:inline-box;display:inline-block;margin:3px 0 4px;margin-left:4px}input{font-family:inherit}body{background:#fff;color:#000}a{color:#4b11a8;text-decoration:none}a:hover,a:active{text-decoration:underline}.fl a{color:#1558d6}a:visited{color:#4b11a8}.sblc{padding-top:5px}.sblc a{display:block;margin:2px 0;margin-left:13px;font-size:11px}.lsbb{background:#f8f9fa;border:solid 1px;border-color:#dadce0 #70757a #70757a #dadce0;height:30px}.lsbb{display:block}#WqQANb a{display:inline-block;margin:0 12px}.lsb{background:url(/images/nav_logo229.png) 0 -261px repeat-x;border:none;color:#000;cursor:pointer;height:30px;margin:0;outline:0;font:15px arial,sans-serif;vertical-align:top}.lsb:active{background:#dadce0}.lst:focus{outline:none}</style><script nonce="zXcc4tMJWBRoE7q_o_Z2fQ">(function(){window.google.erd={jsr:1,bv:1698,de:true};var h=this||self;var k,l=null!=(k=h.mei)?k:1,n,p=null!=(n=h.sdo)?n:!0,q=0,r,t=google.erd,v=t.jsr;google.ml=function(a,b,d,m,e){e=void 0===e?2:e;b&&(r=a&&a.message);if(google.dl)return google.dl(a,e,d),null;if(0>v){window.console&&console.error(a,d);if(-2===v)throw a;b=!1}else b=!a||!a.message||"Error loading script"===a.message||q>=l&&!m?!1:!0;if(!b)return null;q++;d=d||{};b=encodeURIComponent;var c="/gen_204?atyp=i&ei="+b(google.kEI);google.kEXPI&&(c+="&jexpid="+b(google.kEXPI));c+="&srcpg="+b(google.sn)+"&jsr="+b(t.jsr)+"&bver="+b(t.bv);var f=a.lineNumber;void 0!==f&&(c+="&line="+f);var g=a.fileName;g&&(0<g.indexOf("-extension:/")&&(e=3),c+="&script="+b(g),f&&g===window.location.href&&(f=document.documentElement.outerHTML.split(" ")[f],c+="&cad="+b(f?f.substring(0,300):"No script found.")));c+="&jsel="+e;for(var u in d)c+="&",c+=b(u),c+="=",c+=b(d[u]);c=c+"&emsg="+b(a.name+": "+a.message);c=c+"&jsst="+b(a.stack||"N/A");12288<=c.length&&(c=c.substr(0,12288));a=c;m||google.log(0,"",a);return a};window.onerror=function(a,b,d,m,e){r!==a&&(a=e instanceof Error?e:Error(a),void 0===d||"lineNumber"in a||(a.lineNumber=d),void 0===b||"fileName"in a||(a.fileName=b),google.ml(a,!1,void 0,!1,"SyntaxError"===a.name||"SyntaxError"===a.message.substring(0,11)||-1!==a.message.indexOf("Script error")?3:0));r=null;p&&q>=l&&(window.onerror=null)};})();</script></head><body bgcolor="#fff"><script nonce="zXcc4tMJWBRoE7q_o_Z2fQ">(function(){var src='/images/nav_logo229.png';var iesg=false;document.body.onload = function(){window.n && window.n();if (document.images){new Image().src=src;}if (!iesg){document.f&&document.f.q.focus();document.gbqf&&document.gbqf.q.focus();}}})();</script><div id="mngb"><div id=gbar><nobr><b class=gb1>B�squeda</b> <a class=gb1 href="https://www.google.es/imghp?hl=es&tab=wi">Im�genes</a> <a class=gb1 href="https://maps.google.es/maps?hl=es&tab=wl">Maps</a> <a class=gb1 href="https://play.google.com/?hl=es&tab=w8">Play</a> <a class=gb1 href="https://www.youtube.com/?tab=w1">YouTube</a> <a class=gb1 href="https://news.google.com/?tab=wn">Noticias</a> <a class=gb1 href="https://mail.google.com/mail/?tab=wm">Gmail</a> <a class=gb1 href="https://drive.google.com/?tab=wo">Drive</a> <a class=gb1 style="text-decoration:none" href="https://www.google.es/intl/es/about/products?tab=wh"><u>M�s</u> »</a></nobr></div><div id=guser width=100%><nobr><span id=gbn class=gbi></span><span id=gbf class=gbf></span><span id=gbe></span><a href="http://www.google.es/history/optout?hl=es" class=gb4>Historial web</a> | <a href="/preferences?hl=es" class=gb4>Ajustes</a> | <a target=_top id=gb_70 href="https://accounts.google.com/ServiceLogin?hl=es&passive=true&continue=https://www.google.com/&ec=GAZAAQ" class=gb4>Iniciar sesi�n</a></nobr></div><div class=gbh style=left:0></div><div class=gbh style=right:0></div></div><center><br clear="all" id="lgpd"><div id="lga"><img alt="Google" height="92" src="/images/branding/googlelogo/1x/googlelogo_white_background_color_272x92dp.png" style="padding:28px 0 14px" width="272" id="hplogo"><br><br></div><form action="/search" name="f"><table cellpadding="0" cellspacing="0"><tr valign="top"><td width="25%"> </td><td align="center" nowrap=""><input name="ie" value="ISO-8859-1" type="hidden"><input value="es" name="hl" type="hidden"><input name="source" type="hidden" value="hp"><input name="biw" type="hidden"><input name="bih" type="hidden"><div class="ds" style="height:32px;margin:4px 0"><input class="lst" style="margin:0;padding:5px 8px 0 6px;vertical-align:top;color:#000" autocomplete="off" value="" title="Buscar con Google" maxlength="2048" name="q" size="57"></div><br style="line-height:0"><span class="ds"><span class="lsbb"><input class="lsb" value="Buscar con Google" name="btnG" type="submit"></span></span><span class="ds"><span class="lsbb"><input class="lsb" id="tsuid_1" value="Voy a tener suerte" name="btnI" type="submit"><script nonce="zXcc4tMJWBRoE7q_o_Z2fQ">(function(){var id='tsuid_1';document.getElementById(id).onclick = function(){if (this.form.q.value){this.checked = 1;if (this.form.iflsig)this.form.iflsig.disabled = false;}else top.location='/doodles/';};})();</script><input value="AJiK0e8AAAAAY46fQwdyVrbrgW6gkEtVkGfp2nyO0ZXL" name="iflsig" type="hidden"></span></span></td><td class="fl sblc" align="left" nowrap="" width="25%"><a href="/advanced_search?hl=es&authuser=0">B�squeda avanzada</a></td></tr></table><input id="gbv" name="gbv" type="hidden" value="1"><script nonce="zXcc4tMJWBRoE7q_o_Z2fQ">(function(){var a,b="1";if(document&&document.getElementById)if("undefined"!=typeof XMLHttpRequest)b="2";else if("undefined"!=typeof ActiveXObject){var c,d,e=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"];for(c=0;d=e[c++];)try{new ActiveXObject(d),b="2"}catch(h){}}a=b;if("2"==a&&-1==location.search.indexOf("&gbv=2")){var f=google.gbvu,g=document.getElementById("gbv");g&&(g.value=a);f&&window.setTimeout(function(){location.href=f},0)};}).call(this);</script></form><div id="gac_scont"></div><div style="font-size:83%;min-height:3.5em"><br><div id="gws-output-pages-elements-homepage_additional_languages__als"><style>#gws-output-pages-elements-homepage_additional_languages__als{font-size:small;margin-bottom:24px}#SIvCob{color:#3c4043;display:inline-block;line-height:28px;}#SIvCob a{padding:0 3px;}.H6sW5{display:inline-block;margin:0 2px;white-space:nowrap}.z4hgWe{display:inline-block;margin:0 2px}</style><div id="SIvCob">Ofrecido por Google en: <a href="https://www.google.com/setprefs?sig=0_vwUKUD2Xhro4NnrueK1hCfItt30%3D&hl=ca&source=homepage&sa=X&ved=0ahUKEwjjw_C44uP7AhW_UaQEHVbMChoQ2ZgBCAU">catal�</a> <a href="https://www.google.com/setprefs?sig=0_vwUKUD2Xhro4NnrueK1hCfItt30%3D&hl=gl&source=homepage&sa=X&ved=0ahUKEwjjw_C44uP7AhW_UaQEHVbMChoQ2ZgBCAY">galego</a> <a href="https://www.google.com/setprefs?sig=0_vwUKUD2Xhro4NnrueK1hCfItt30%3D&hl=eu&source=homepage&sa=X&ved=0ahUKEwjjw_C44uP7AhW_UaQEHVbMChoQ2ZgBCAc">euskara</a> </div></div></div><span id="footer"><div style="font-size:10pt"><div style="margin:19px auto;text-align:center" id="WqQANb"><a href="http://www.google.es/intl/es/services/">Soluciones Empresariales</a><a href="/intl/es/about.html">Todo acerca de Google</a><a href="https://www.google.com/setprefdomain?prefdom=ES&prev=https://www.google.es/&sig=K_a2UXepORMQOw5-SHU8h4noB_VWk%3D">Google.es</a></div></div><p style="font-size:8pt;color:#70757a">© 2022 - <a href="/intl/es/policies/privacy/">Privacidad</a> - <a href="/intl/es/policies/terms/">T�rminos</a></p></span></center><script nonce="zXcc4tMJWBRoE7q_o_Z2fQ">(function(){window.google.cdo={height:757,width:1440};(function(){var a=window.innerWidth,b=window.innerHeight;if(!a||!b){var c=window.document,d="CSS1Compat"==c.compatMode?c.documentElement:c.body;a=d.clientWidth;b=d.clientHeight}a&&b&&(a!=google.cdo.width||b!=google.cdo.height)&&google.log("","","/client_204?&atyp=i&biw="+a+"&bih="+b+"&ei="+google.kEI);}).call(this);})();</script> <script nonce="zXcc4tMJWBRoE7q_o_Z2fQ">(function(){google.xjs={ck:'xjs.hp.oxai9SxkIQY.L.X.O',cs:'ACT90oEGh-_ImDfBjn6aD_ABGaOlD2MqVw',excm:[]};})();</script> <script nonce="zXcc4tMJWBRoE7q_o_Z2fQ">(function(){var u='/xjs/_/js/k=xjs.hp.en.9b-uVUIpJU8.O/am=AADoBABQAGAB/d=1/ed=1/rs=ACT90oG-6KYVksw4jxVvNcwan406xE6qVw/m=sb_he,d';var amd=0;var d=this||self,e=function(a){return a};var g;var l=function(a,b){this.g=b===h?a:""};l.prototype.toString=function(){return this.g+""};var h={};function m(){var a=u;google.lx=function(){p(a);google.lx=function(){}};google.bx||google.lx()}function p(a){google.timers&&google.timers.load&&google.tick&&google.tick("load","xjsls");var b=document;var c="SCRIPT";"application/xhtml+xml"===b.contentType&&(c=c.toLowerCase());c=b.createElement(c);if(void 0===g){b=null;var k=d.trustedTypes;if(k&&k.createPolicy){try{b=k.createPolicy("goog#html",{createHTML:e,createScript:e,createScriptURL:e})}catch(q){d.console&&d.console.error(q.message)}g=b}else g=b}a=(b=g)?b.createScriptURL(a):a;a=new l(a,h);c.src=a instanceof l&&a.constructor===l?a.g:"type_error:TrustedResourceUrl";var f,n;(f=(a=null==(n=(f=(c.ownerDocument&&c.ownerDocument.defaultView||window).document).querySelector)?void 0:n.call(f,"script[nonce]"))?a.nonce||a.getAttribute("nonce")||"":"")&&c.setAttribute("nonce",f);document.body.appendChild(c);google.psa=!0};google.xjsu=u;setTimeout(function(){0<amd?google.caft(function(){return m()},amd):m()},0);})();function _DumpException(e){throw e;}function _F_installCss(c){}(function(){google.jl={blt:'none',chnk:0,dw:false,dwu:true,emtn:0,end:0,ico:false,ikb:0,ine:false,injs:'none',injt:0,injth:0,injv2:false,lls:'default',pdt:0,rep:0,snet:true,strt:0,ubm:false,uwp:true};})();(function(){var pmc='{"d":{},"sb_he":{"agen":true,"cgen":true,"client":"heirloom-hp","dh":true,"ds":"","fl":true,"host":"google.com","jsonp":true,"lm":true,"msgs":{"cibl":"Borrar b�squeda","dym":"Quiz�s quisiste decir:","lcky":"Voy a tener suerte","lml":"M�s informaci�n","psrc":"Esta b�squeda se ha eliminado de tu \u003Ca href=\"/history\"\u003Ehistorial web\u003C/a\u003E.","psrl":"Eliminar","sbit":"Buscar por imagen","srch":"Buscar con Google"},"ovr":{},"pq":"","rfs":[],"sbas":"0 3px 8px 0 rgba(0,0,0,0.2),0 0 0 1px rgba(0,0,0,0.08)","stok":"gh8wSanWNWQy8f-PH0wGTjDkvYQ"}}';google.pmc=JSON.parse(pmc);})();</script> </body></html>
We can also create a pipeline to save it to a file
!curl https://www.google.com > google.html
% Total % Received % Xferd Average Speed Time Time Time CurrentDload Upload Total Spent Left Speed100 15168 0 15168 0 0 135k 0 --:--:-- --:--:-- --:--:-- 137k
Now we can see if it has saved correctly
!cat google.html
<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="es"><head><meta content="Google.es permite acceder a la informaci�n mundial en castellano, catal�n, gallego, euskara e ingl�s." name="description"><meta content="noodp" name="robots"><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"><meta content="/images/branding/googleg/1x/googleg_standard_color_128dp.png" itemprop="image"><title>Google</title><script nonce="Jo7WFU6XWWwu6NrdwaRyIw">(function(){window.google={kEI:'R5GOY-LZHLegkdUP_IqzoAE',kEXPI:'0,1359409,6059,206,4804,2316,383,246,5,5367,1123753,1197777,380713,16115,28684,22430,1362,283,12036,17580,4998,13228,516,3331,10622,22741,5081,1593,1279,2742,149,1103,840,1983,4,210,4100,3514,606,2023,2299,14668,3229,2843,7,4773,826,23475,4696,1851,15756,3,346,230,6459,149,13975,4,1528,2304,7039,20309,7422,7357,13658,4437,16786,5812,2545,4094,4052,3,3541,1,11943,30211,2,8984,1,5037,6249,19490,5679,1020,2378,28745,4568,6258,23418,1252,5835,14967,4333,4239,3245,27082,239,7916,7381,15969,874,19633,6,1923,5784,3995,21779,1120,8423,4832,26080,423,107,5690,3,14433,3890,751,14879,3,683,217,1405,1779,1854,31,1966,1119,6,8909,323,5659,1741,814,1224,10,280,2346,82,1419,3,565,401,519,68,970,1125,440,398,156,367,1034,333,3392,526,396,3,1431,3,785,2,312,2312,196,907,342,244,618,314,1,293,568,171,1104,14,89,891,56,857,306,14,509,154,246,1110,219,628,249,229,49,8,8,3,55,4,399,55,39,1072,49,43,2,468,782,83,123,641,1502,166,350,707,195,5,140,358,329,692,109,1,20,108,134,547,67,5,49,93,31,77,124,79,355,160,27,829,236,764,12,35,118,98,803,1,65,436,5,5,54,2065,262,5,3,647,3,8,2,14,39,65,380,80,14,790,346,115,99,1323,4,711,242,2,723,2286,5280608,12,5934,147,81,8798948,3311,141,795,19735,1,1,346,1755,1004,41,342,1,189,14,9,4,6,3,3,4,1,2,2,3,2,2,2,1,2,5,2,2,1,2,2,2,23947077,512,18,13,2737921,1303678,1964,3094,13579,3405,5595,11,3835,1923,3208,1069,1480676,40778',kBL:'p9Xv'};google.sn='webhp';google.kHL='es';})();(function(){var f=this||self;var h,k=[];function l(a){for(var b;a&&(!a.getAttribute||!(b=a.getAttribute("eid")));)a=a.parentNode;return b||h}function m(a){for(var b=null;a&&(!a.getAttribute||!(b=a.getAttribute("leid")));)a=a.parentNode;return b}function n(a,b,c,d,g){var e="";c||-1!==b.search("&ei=")||(e="&ei="+l(d),-1===b.search("&lei=")&&(d=m(d))&&(e+="&lei="+d));d="";!c&&f._cshid&&-1===b.search("&cshid=")&&"slh"!==a&&(d="&cshid="+f._cshid);c=c||"/"+(g||"gen_204")+"?atyp=i&ct="+a+"&cad="+b+e+"&zx="+Date.now()+d;/^http:/i.test(c)&&"https:"===window.location.protocol&&(google.ml&&google.ml(Error("a"),!1,{src:c,glmm:1}),c="");return c};h=google.kEI;google.getEI=l;google.getLEI=m;google.ml=function(){return null};google.log=function(a,b,c,d,g){if(c=n(a,b,c,d,g)){a=new Image;var e=k.length;k[e]=a;a.onerror=a.onload=a.onabort=function(){delete k[e]};a.src=c}};google.logUrl=n;}).call(this);(function(){google.y={};google.sy=[];google.x=function(a,b){if(a)var c=a.id;else{do c=Math.random();while(google.y[c])}google.y[c]=[a,b];return!1};google.sx=function(a){google.sy.push(a)};google.lm=[];google.plm=function(a){google.lm.push.apply(google.lm,a)};google.lq=[];google.load=function(a,b,c){google.lq.push([[a],b,c])};google.loadAll=function(a,b){google.lq.push([a,b])};google.bx=!1;google.lx=function(){};}).call(this);google.f={};(function(){document.documentElement.addEventListener("submit",function(b){var a;if(a=b.target){var c=a.getAttribute("data-submitfalse");a="1"===c||"q"===c&&!a.elements.q.value?!0:!1}else a=!1;a&&(b.preventDefault(),b.stopPropagation())},!0);document.documentElement.addEventListener("click",function(b){var a;a:{for(a=b.target;a&&a!==document.documentElement;a=a.parentElement)if("A"===a.tagName){a="1"===a.getAttribute("data-nohref");break a}a=!1}a&&b.preventDefault()},!0);}).call(this);</script><style>#gbar,#guser{font-size:13px;padding-top:1px !important;}#gbar{height:22px}#guser{padding-bottom:7px !important;text-align:right}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}@media all{.gb1{height:22px;margin-right:.5em;vertical-align:top}#gbar{float:left}}a.gb1,a.gb4{text-decoration:underline !important}a.gb1,a.gb4{color:#00c !important}.gbi .gb4{color:#dd8e27 !important}.gbf .gb4{color:#900 !important}</style><style>body,td,a,p,.h{font-family:arial,sans-serif}body{margin:0;overflow-y:scroll}#gog{padding:3px 8px 0}td{line-height:.8em}.gac_m td{line-height:17px}form{margin-bottom:20px}.h{color:#1558d6}em{font-weight:bold;font-style:normal}.lst{height:25px;width:496px}.gsfi,.lst{font:18px arial,sans-serif}.gsfs{font:17px arial,sans-serif}.ds{display:inline-box;display:inline-block;margin:3px 0 4px;margin-left:4px}input{font-family:inherit}body{background:#fff;color:#000}a{color:#4b11a8;text-decoration:none}a:hover,a:active{text-decoration:underline}.fl a{color:#1558d6}a:visited{color:#4b11a8}.sblc{padding-top:5px}.sblc a{display:block;margin:2px 0;margin-left:13px;font-size:11px}.lsbb{background:#f8f9fa;border:solid 1px;border-color:#dadce0 #70757a #70757a #dadce0;height:30px}.lsbb{display:block}#WqQANb a{display:inline-block;margin:0 12px}.lsb{background:url(/images/nav_logo229.png) 0 -261px repeat-x;border:none;color:#000;cursor:pointer;height:30px;margin:0;outline:0;font:15px arial,sans-serif;vertical-align:top}.lsb:active{background:#dadce0}.lst:focus{outline:none}</style><script nonce="Jo7WFU6XWWwu6NrdwaRyIw">(function(){window.google.erd={jsr:1,bv:1698,de:true};var h=this||self;var k,l=null!=(k=h.mei)?k:1,n,p=null!=(n=h.sdo)?n:!0,q=0,r,t=google.erd,v=t.jsr;google.ml=function(a,b,d,m,e){e=void 0===e?2:e;b&&(r=a&&a.message);if(google.dl)return google.dl(a,e,d),null;if(0>v){window.console&&console.error(a,d);if(-2===v)throw a;b=!1}else b=!a||!a.message||"Error loading script"===a.message||q>=l&&!m?!1:!0;if(!b)return null;q++;d=d||{};b=encodeURIComponent;var c="/gen_204?atyp=i&ei="+b(google.kEI);google.kEXPI&&(c+="&jexpid="+b(google.kEXPI));c+="&srcpg="+b(google.sn)+"&jsr="+b(t.jsr)+"&bver="+b(t.bv);var f=a.lineNumber;void 0!==f&&(c+="&line="+f);var g=a.fileName;g&&(0<g.indexOf("-extension:/")&&(e=3),c+="&script="+b(g),f&&g===window.location.href&&(f=document.documentElement.outerHTML.split(" ")[f],c+="&cad="+b(f?f.substring(0,300):"No script found.")));c+="&jsel="+e;for(var u in d)c+="&",c+=b(u),c+="=",c+=b(d[u]);c=c+"&emsg="+b(a.name+": "+a.message);c=c+"&jsst="+b(a.stack||"N/A");12288<=c.length&&(c=c.substr(0,12288));a=c;m||google.log(0,"",a);return a};window.onerror=function(a,b,d,m,e){r!==a&&(a=e instanceof Error?e:Error(a),void 0===d||"lineNumber"in a||(a.lineNumber=d),void 0===b||"fileName"in a||(a.fileName=b),google.ml(a,!1,void 0,!1,"SyntaxError"===a.name||"SyntaxError"===a.message.substring(0,11)||-1!==a.message.indexOf("Script error")?3:0));r=null;p&&q>=l&&(window.onerror=null)};})();</script></head><body bgcolor="#fff"><script nonce="Jo7WFU6XWWwu6NrdwaRyIw">(function(){var src='/images/nav_logo229.png';var iesg=false;document.body.onload = function(){window.n && window.n();if (document.images){new Image().src=src;}if (!iesg){document.f&&document.f.q.focus();document.gbqf&&document.gbqf.q.focus();}}})();</script><div id="mngb"><div id=gbar><nobr><b class=gb1>B�squeda</b> <a class=gb1 href="https://www.google.es/imghp?hl=es&tab=wi">Im�genes</a> <a class=gb1 href="https://maps.google.es/maps?hl=es&tab=wl">Maps</a> <a class=gb1 href="https://play.google.com/?hl=es&tab=w8">Play</a> <a class=gb1 href="https://www.youtube.com/?tab=w1">YouTube</a> <a class=gb1 href="https://news.google.com/?tab=wn">Noticias</a> <a class=gb1 href="https://mail.google.com/mail/?tab=wm">Gmail</a> <a class=gb1 href="https://drive.google.com/?tab=wo">Drive</a> <a class=gb1 style="text-decoration:none" href="https://www.google.es/intl/es/about/products?tab=wh"><u>M�s</u> »</a></nobr></div><div id=guser width=100%><nobr><span id=gbn class=gbi></span><span id=gbf class=gbf></span><span id=gbe></span><a href="http://www.google.es/history/optout?hl=es" class=gb4>Historial web</a> | <a href="/preferences?hl=es" class=gb4>Ajustes</a> | <a target=_top id=gb_70 href="https://accounts.google.com/ServiceLogin?hl=es&passive=true&continue=https://www.google.com/&ec=GAZAAQ" class=gb4>Iniciar sesi�n</a></nobr></div><div class=gbh style=left:0></div><div class=gbh style=right:0></div></div><center><br clear="all" id="lgpd"><div id="lga"><img alt="Google" height="92" src="/images/branding/googlelogo/1x/googlelogo_white_background_color_272x92dp.png" style="padding:28px 0 14px" width="272" id="hplogo"><br><br></div><form action="/search" name="f"><table cellpadding="0" cellspacing="0"><tr valign="top"><td width="25%"> </td><td align="center" nowrap=""><input name="ie" value="ISO-8859-1" type="hidden"><input value="es" name="hl" type="hidden"><input name="source" type="hidden" value="hp"><input name="biw" type="hidden"><input name="bih" type="hidden"><div class="ds" style="height:32px;margin:4px 0"><input class="lst" style="margin:0;padding:5px 8px 0 6px;vertical-align:top;color:#000" autocomplete="off" value="" title="Buscar con Google" maxlength="2048" name="q" size="57"></div><br style="line-height:0"><span class="ds"><span class="lsbb"><input class="lsb" value="Buscar con Google" name="btnG" type="submit"></span></span><span class="ds"><span class="lsbb"><input class="lsb" id="tsuid_1" value="Voy a tener suerte" name="btnI" type="submit"><script nonce="Jo7WFU6XWWwu6NrdwaRyIw">(function(){var id='tsuid_1';document.getElementById(id).onclick = function(){if (this.form.q.value){this.checked = 1;if (this.form.iflsig)this.form.iflsig.disabled = false;}else top.location='/doodles/';};})();</script><input value="AJiK0e8AAAAAY46fV7gpXBHCT6KAebFZAqGv1l-4BtIR" name="iflsig" type="hidden"></span></span></td><td class="fl sblc" align="left" nowrap="" width="25%"><a href="/advanced_search?hl=es&authuser=0">B�squeda avanzada</a></td></tr></table><input id="gbv" name="gbv" type="hidden" value="1"><script nonce="Jo7WFU6XWWwu6NrdwaRyIw">(function(){var a,b="1";if(document&&document.getElementById)if("undefined"!=typeof XMLHttpRequest)b="2";else if("undefined"!=typeof ActiveXObject){var c,d,e=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"];for(c=0;d=e[c++];)try{new ActiveXObject(d),b="2"}catch(h){}}a=b;if("2"==a&&-1==location.search.indexOf("&gbv=2")){var f=google.gbvu,g=document.getElementById("gbv");g&&(g.value=a);f&&window.setTimeout(function(){location.href=f},0)};}).call(this);</script></form><div id="gac_scont"></div><div style="font-size:83%;min-height:3.5em"><br><div id="gws-output-pages-elements-homepage_additional_languages__als"><style>#gws-output-pages-elements-homepage_additional_languages__als{font-size:small;margin-bottom:24px}#SIvCob{color:#3c4043;display:inline-block;line-height:28px;}#SIvCob a{padding:0 3px;}.H6sW5{display:inline-block;margin:0 2px;white-space:nowrap}.z4hgWe{display:inline-block;margin:0 2px}</style><div id="SIvCob">Ofrecido por Google en: <a href="https://www.google.com/setprefs?sig=0_HljXEzVisqsnlJP1S5dx0Fao0Lw%3D&hl=ca&source=homepage&sa=X&ved=0ahUKEwiimaPC4uP7AhU3UKQEHXzFDBQQ2ZgBCAU">catal�</a> <a href="https://www.google.com/setprefs?sig=0_HljXEzVisqsnlJP1S5dx0Fao0Lw%3D&hl=gl&source=homepage&sa=X&ved=0ahUKEwiimaPC4uP7AhU3UKQEHXzFDBQQ2ZgBCAY">galego</a> <a href="https://www.google.com/setprefs?sig=0_HljXEzVisqsnlJP1S5dx0Fao0Lw%3D&hl=eu&source=homepage&sa=X&ved=0ahUKEwiimaPC4uP7AhU3UKQEHXzFDBQQ2ZgBCAc">euskara</a> </div></div></div><span id="footer"><div style="font-size:10pt"><div style="margin:19px auto;text-align:center" id="WqQANb"><a href="http://www.google.es/intl/es/services/">Soluciones Empresariales</a><a href="/intl/es/about.html">Todo acerca de Google</a><a href="https://www.google.com/setprefdomain?prefdom=ES&prev=https://www.google.es/&sig=K_8O8QHBmoai9DOT5YZxMWevJK8VI%3D">Google.es</a></div></div><p style="font-size:8pt;color:#70757a">© 2022 - <a href="/intl/es/policies/privacy/">Privacidad</a> - <a href="/intl/es/policies/terms/">T�rminos</a></p></span></center><script nonce="Jo7WFU6XWWwu6NrdwaRyIw">(function(){window.google.cdo={height:757,width:1440};(function(){var a=window.innerWidth,b=window.innerHeight;if(!a||!b){var c=window.document,d="CSS1Compat"==c.compatMode?c.documentElement:c.body;a=d.clientWidth;b=d.clientHeight}a&&b&&(a!=google.cdo.width||b!=google.cdo.height)&&google.log("","","/client_204?&atyp=i&biw="+a+"&bih="+b+"&ei="+google.kEI);}).call(this);})();</script> <script nonce="Jo7WFU6XWWwu6NrdwaRyIw">(function(){google.xjs={ck:'xjs.hp.oxai9SxkIQY.L.X.O',cs:'ACT90oEGh-_ImDfBjn6aD_ABGaOlD2MqVw',excm:[]};})();</script> <script nonce="Jo7WFU6XWWwu6NrdwaRyIw">(function(){var u='/xjs/_/js/k=xjs.hp.en.9b-uVUIpJU8.O/am=AADoBABQAGAB/d=1/ed=1/rs=ACT90oG-6KYVksw4jxVvNcwan406xE6qVw/m=sb_he,d';var amd=0;var d=this||self,e=function(a){return a};var g;var l=function(a,b){this.g=b===h?a:""};l.prototype.toString=function(){return this.g+""};var h={};function m(){var a=u;google.lx=function(){p(a);google.lx=function(){}};google.bx||google.lx()}function p(a){google.timers&&google.timers.load&&google.tick&&google.tick("load","xjsls");var b=document;var c="SCRIPT";"application/xhtml+xml"===b.contentType&&(c=c.toLowerCase());c=b.createElement(c);if(void 0===g){b=null;var k=d.trustedTypes;if(k&&k.createPolicy){try{b=k.createPolicy("goog#html",{createHTML:e,createScript:e,createScriptURL:e})}catch(q){d.console&&d.console.error(q.message)}g=b}else g=b}a=(b=g)?b.createScriptURL(a):a;a=new l(a,h);c.src=a instanceof l&&a.constructor===l?a.g:"type_error:TrustedResourceUrl";var f,n;(f=(a=null==(n=(f=(c.ownerDocument&&c.ownerDocument.defaultView||window).document).querySelector)?void 0:n.call(f,"script[nonce]"))?a.nonce||a.getAttribute("nonce")||"":"")&&c.setAttribute("nonce",f);document.body.appendChild(c);google.psa=!0};google.xjsu=u;setTimeout(function(){0<amd?google.caft(function(){return m()},amd):m()},0);})();function _DumpException(e){throw e;}function _F_installCss(c){}(function(){google.jl={blt:'none',chnk:0,dw:false,dwu:true,emtn:0,end:0,ico:false,ikb:0,ine:false,injs:'none',injt:0,injth:0,injv2:false,lls:'default',pdt:0,rep:0,snet:true,strt:0,ubm:false,uwp:true};})();(function(){var pmc='{"d":{},"sb_he":{"agen":true,"cgen":true,"client":"heirloom-hp","dh":true,"ds":"","fl":true,"host":"google.com","jsonp":true,"lm":true,"msgs":{"cibl":"Borrar b�squeda","dym":"Quiz�s quisiste decir:","lcky":"Voy a tener suerte","lml":"M�s informaci�n","psrc":"Esta b�squeda se ha eliminado de tu \u003Ca href=\"/history\"\u003Ehistorial web\u003C/a\u003E.","psrl":"Eliminar","sbit":"Buscar por imagen","srch":"Buscar con Google"},"ovr":{},"pq":"","rfs":[],"sbas":"0 3px 8px 0 rgba(0,0,0,0.2),0 0 0 1px rgba(0,0,0,0.08)","stok":"GYSMF2y7hymT0L3W0W4RPVIsSrU"}}';google.pmc=JSON.parse(pmc);})();</script> </body></html>
Download files with wget
Another similar command is wget
, however, unlike curl
, wget
downloads the file directly.
!wget https://www.google.com
--2022-12-06 01:49:19-- https://www.google.com/Resolviendo www.google.com (www.google.com)... 142.250.200.68, 2a00:1450:4003:80c::2004Conectando con www.google.com (www.google.com)[142.250.200.68]:443... conectado.Petición HTTP enviada, esperando respuesta... 200 OKLongitud: no especificado [text/html]Guardando como: “index.html.1”index.html.1 [ <=> ] 14,76K --.-KB/s en 0,002s2022-12-06 01:49:19 (7,17 MB/s) - “index.html.1” guardado [15117]
!ls -l
total 316-rw-rw-r-- 1 wallabot wallabot 285898 dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt-rw-rw-r-- 1 wallabot wallabot 15168 dic 6 01:48 google.html-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html-rw-rw-r-- 1 wallabot wallabot 15117 dic 6 01:49 index.html.1-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txt
We see that it has been saved as index.html
, which is how Google has it named.
If we want to save it with a specific name, we can use the -O
flag
!wget https://www.google.com -O google2.html
--2022-12-06 01:49:37-- https://www.google.com/Resolviendo www.google.com (www.google.com)... 142.250.200.68, 2a00:1450:4003:80c::2004Conectando con www.google.com (www.google.com)[142.250.200.68]:443... conectado.Petición HTTP enviada, esperando respuesta... 200 OKLongitud: no especificado [text/html]Guardando como: “google2.html”google2.html [ <=> ] 14,78K --.-KB/s en 0,003s2022-12-06 01:49:37 (5,27 MB/s) - “google2.html” guardado [15131]
!ls -l
total 332-rw-rw-r-- 1 wallabot wallabot 285898 dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt-rw-rw-r-- 1 wallabot wallabot 15131 dic 6 01:49 google2.html-rw-rw-r-- 1 wallabot wallabot 15168 dic 6 01:48 google.html-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html-rw-rw-r-- 1 wallabot wallabot 15117 dic 6 01:49 index.html.1-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txt
Path Debugging with traceroute
A very useful command is to see the route to a destination, for this we use traceroute
, for example, let's see all the sites I have to pass through to connect to Google
!traceroute www.google.com
traceroute to www.google.com (142.250.200.68), 64 hops max1 192.168.1.1 0,435ms 0,154ms 0,133ms2 188.127.176.1 3,979ms 2,914ms 3,397ms3 10.15.0.77 3,600ms 3,914ms 2,669ms4 10.15.246.6 3,567ms 3,713ms 2,926ms5 * * *6 72.14.209.84 3,981ms 2,914ms 2,993ms7 * * *8 142.251.54.148 3,856ms 2,916ms 2,905ms9 142.250.200.68 2,908ms 2,949ms 3,037ms
Route Debugging with mtr
Another debugging tool is mtr
, which is an improved version of traceroute
. It provides information for each hop, such as response time, packet loss percentage, etc.
!mtr -n maximofn.com
wallabot (192.168.178.144)Keys: Help Display mode Restart statistics Order of fields quitPackets PingsHost Loss% Snt Last Avg Best Wrst StDev1. 192.168.178.1 0.0% 345 0.3 0.3 0.3 0.3 0.02. 192.168.0.1 0.0% 344 0.8 1.1 1.1 1.1 0.03. (waiting for reply)4. 10.183.52.41 0.0% 344 2.8 2.5 2.5 2.5 0.05. 172.29.0.161 47.7% 344 2.3 3.1 3.1 23.1 0.06. (waiting for reply)7. 193.149.1.97 0.0% 344 3.6 3.6 3.6 38.6 0.08. (waiting for reply)9. 185.125.78.197 2.9% 344 6.9 6.9 6.9 6.9 0.0
As you can see in hop 5, almost 50% of the packets are lost, which would help me call my phone company and ask them to try routing me through a different path.
Name of our machine with hostname
If we want to know the name of our machine, we can use hostname
, which is useful if we want to connect to our machine from another one.
!hostname
wallabot
Default gateway information with route -n
If we want to know our default gateway we use the command route -n
!route -n
Tabla de rutas IP del núcleoDestino Pasarela Genmask Indic Métric Ref Uso Interfaz0.0.0.0 192.168.1.1 0.0.0.0 UG 100 0 0 enp6s0169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 enp6s0172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0172.18.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-470e52ae2708192.168.1.0 0.0.0.0 255.255.255.0 U 100 0 0 enp6s0
IP Information of a Domain with nslookup
If we want to know the IP of a domain, we can find it out using the nslookup
command.
!nslookup google.com
Server: 127.0.0.53Address: 127.0.0.53#53Non-authoritative answer:Name: google.comAddress: 142.250.185.14Name: google.comAddress: 2a00:1450:4003:808::200e
This tells us that Google's IPv4 is 172.217.168.174 and its IPv6 is 2a00:1450:4003:803::200e
Information about our network with netstats
The last utility command is netstats
, this command gives us the status of our network, and with the -i
flag it returns our network interfaces.
!netstat -i
Tabla de la interfaz del núcleoIface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flgbr-470e5 1500 0 0 0 0 0 0 0 0 BMUdocker0 1500 0 0 0 0 0 0 0 0 BMUenp6s0 1500 148385 0 2182 0 106135 0 0 0 BMRUlo 65536 11674 0 0 0 11674 0 0 0 LRUwlp5s0 1500 0 0 0 0 0 0 0 0 BMU
DNS Queries with dig
With the command dig <domain>
we can make DNS queries, for example, let's make a query to Google
!dig google.com
; <<>> DiG 9.16.1-Ubuntu <<>> google.com;; global options: +cmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20527;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1;; OPT PSEUDOSECTION:; EDNS: version: 0, flags:; udp: 65494;; QUESTION SECTION:;google.com. IN A;; ANSWER SECTION:google.com. 283 IN A 142.250.184.14;; Query time: 8 msec;; SERVER: 127.0.0.53#53(127.0.0.53);; WHEN: dom sep 24 01:32:07 CEST 2023;; MSG SIZE rcvd: 55
It can be seen
```;; ANSWER SECTION:google.com. 283 IN A 142.250.184.14```
Therefore, the query has given us Google's IP
We can query a particular DNS server with dig @<DNS server> <domain>
!dig @1.1.1.1 google.com
; <<>> DiG 9.16.1-Ubuntu <<>> @1.1.1.1 google.com; (1 server found);; global options: +cmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15633;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0;; QUESTION SECTION:;google.com. IN A;; ANSWER SECTION:google.com. 190 IN A 142.250.184.14;; Query time: 8 msec;; SERVER: 1.1.1.1#53(1.1.1.1);; WHEN: dom sep 24 01:33:40 CEST 2023;; MSG SIZE rcvd: 44
We have made the same query, but we have made it to Cloudflare's DNS.
Compressing Files
Before compressing and decompressing, let's see what we are going to compress. First, we print our path and list the files.
!pwd; ls -l
/home/wallabot/Documentos/web/portafolio/posts/pruebatotal 332-rw-rw-r-- 1 wallabot wallabot 285898 dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt-rw-rw-r-- 1 wallabot wallabot 15131 dic 6 01:49 google2.html-rw-rw-r-- 1 wallabot wallabot 15168 dic 6 01:48 google.html-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html-rw-rw-r-- 1 wallabot wallabot 15117 dic 6 01:49 index.html.1-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txt
Let's create a new folder and copy everything that is inside the current folder into it.
!mkdir tocompress; cp * tocompress; ls -l
cp: -r not specified; omitting directory 'tocompress'total 336-rw-rw-r-- 1 wallabot wallabot 285898 dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt-rw-rw-r-- 1 wallabot wallabot 15131 dic 6 01:49 google2.html-rw-rw-r-- 1 wallabot wallabot 15168 dic 6 01:48 google.html-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html-rw-rw-r-- 1 wallabot wallabot 15117 dic 6 01:49 index.html.1-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txtdrwxrwxr-x 2 wallabot wallabot 4096 dic 6 01:52 tocompress
As we can see, everything except the tocompress
folder itself has been copied because we did not use the -r
flag in the cp
command. But what happened is what we wanted.
Compress with tar
The first command we are going to use to compress is tar
to which we will add the -c
flag for compress, -v
for verbose, so it will show us what it is doing, and the -f
flag for file, followed by the name we want for the compressed file and the name of the file we want to compress.
!tar -cvf tocompress.tar tocompress
tocompress/tocompress/lista.txttocompress/dot.txttocompress/google.htmltocompress/index.htmltocompress/Abctocompress/google2.htmltocompress/dot2.txttocompress/secuential.txttocompress/index.html.1tocompress/file.txttocompress/datos1tocompress/2021-02-11-Introduccion-a-Python.ipynbtocompress/datos123
!ls -l
total 676-rw-rw-r-- 1 wallabot wallabot 285898 dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt-rw-rw-r-- 1 wallabot wallabot 15131 dic 6 01:49 google2.html-rw-rw-r-- 1 wallabot wallabot 15168 dic 6 01:48 google.html-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html-rw-rw-r-- 1 wallabot wallabot 15117 dic 6 01:49 index.html.1-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txtdrwxrwxr-x 2 wallabot wallabot 4096 dic 6 01:52 tocompress-rw-rw-r-- 1 wallabot wallabot 348160 dic 6 01:53 tocompress.tar
We see that the file tocompress.tar
has been created.
Now we are going to repeat the process, but adding the -z
flag, which compresses in the gzip
format, a more efficient compression algorithm
!tar -cvzf tocompress.tar.gz tocompress
tocompress/tocompress/lista.txttocompress/dot.txttocompress/google.htmltocompress/index.htmltocompress/Abctocompress/google2.htmltocompress/dot2.txttocompress/secuential.txttocompress/index.html.1tocompress/file.txttocompress/datos1tocompress/2021-02-11-Introduccion-a-Python.ipynbtocompress/datos123
!ls -lh
total 728K-rw-rw-r-- 1 wallabot wallabot 280K dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:49 google2.html-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:48 google.html-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:49 index.html.1-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txtdrwxrwxr-x 2 wallabot wallabot 4,0K dic 6 01:52 tocompress-rw-rw-r-- 1 wallabot wallabot 340K dic 6 01:53 tocompress.tar-rw-rw-r-- 1 wallabot wallabot 52K dic 6 01:53 tocompress.tar.gz
As you can see, the file tocompress.tar
occupies 340 kB
, while the file tocompress.tar.gz
occupies only 52 kB
.
Now we are going to decompress the files. To decompress, the same command is used, only changing the -c
flag to the -x
flag
First, we delete the original folder
!rm -r tocompress
We decompress
!rm -r tocompress!tar -xvf tocompress.tar
tocompress/tocompress/lista.txttocompress/dot.txttocompress/google.htmltocompress/index.htmltocompress/Abctocompress/google2.htmltocompress/dot2.txttocompress/secuential.txttocompress/index.html.1tocompress/file.txttocompress/datos1tocompress/2021-02-11-Introduccion-a-Python.ipynbtocompress/datos123
!ls -lh
total 728K-rw-rw-r-- 1 wallabot wallabot 280K dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:49 google2.html-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:48 google.html-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:49 index.html.1-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txtdrwxrwxr-x 2 wallabot wallabot 4,0K dic 6 01:52 tocompress-rw-rw-r-- 1 wallabot wallabot 340K dic 6 01:53 tocompress.tar-rw-rw-r-- 1 wallabot wallabot 52K dic 6 01:53 tocompress.tar.gz
We do the same with gzip
!rm -r tocompress
!rm -r tocompress!tar -xvzf tocompress.tar.gz
tocompress/tocompress/lista.txttocompress/dot.txttocompress/google.htmltocompress/index.htmltocompress/Abctocompress/google2.htmltocompress/dot2.txttocompress/secuential.txttocompress/index.html.1tocompress/file.txttocompress/datos1tocompress/2021-02-11-Introduccion-a-Python.ipynbtocompress/datos123
!ls -lh
total 728K-rw-rw-r-- 1 wallabot wallabot 280K dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:49 google2.html-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:48 google.html-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:49 index.html.1-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txtdrwxrwxr-x 2 wallabot wallabot 4,0K dic 6 01:52 tocompress-rw-rw-r-- 1 wallabot wallabot 340K dic 6 01:53 tocompress.tar-rw-rw-r-- 1 wallabot wallabot 52K dic 6 01:53 tocompress.tar.gz
Compress with zip
Another command to compress is zip
. To compress, you only need to add the -r
(recursive) flag, the name you want for the compressed file, and the file you want to compress.
!zip -r tocompress.zip tocompress
adding: tocompress/ (stored 0%)adding: tocompress/lista.txt (deflated 23%)adding: tocompress/dot.txt (stored 0%)adding: tocompress/google.html (deflated 56%)adding: tocompress/index.html (stored 0%)adding: tocompress/Abc (stored 0%)adding: tocompress/google2.html (deflated 56%)adding: tocompress/dot2.txt (stored 0%)adding: tocompress/secuential.txt (stored 0%)adding: tocompress/index.html.1 (deflated 56%)adding: tocompress/file.txt (stored 0%)adding: tocompress/datos1 (stored 0%)adding: tocompress/2021-02-11-Introduccion-a-Python.ipynb (deflated 85%)adding: tocompress/datos123 (stored 0%)
!ls -lh
total 792K-rw-rw-r-- 1 wallabot wallabot 280K dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:49 google2.html-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:48 google.html-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:49 index.html.1-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txtdrwxrwxr-x 2 wallabot wallabot 4,0K dic 6 01:52 tocompress-rw-rw-r-- 1 wallabot wallabot 340K dic 6 01:53 tocompress.tar-rw-rw-r-- 1 wallabot wallabot 52K dic 6 01:53 tocompress.tar.gz-rw-rw-r-- 1 wallabot wallabot 64K dic 6 01:53 tocompress.zip
To unzip, the unzip
command is used followed by the name of the file you want to unzip. First, we delete the tocompress
folder.
!rm -r tocompress
!rm -r tocompress!unzip tocompress.zip
Archive: tocompress.zipcreating: tocompress/inflating: tocompress/lista.txtextracting: tocompress/dot.txtinflating: tocompress/google.htmlextracting: tocompress/index.htmlextracting: tocompress/Abcinflating: tocompress/google2.htmlextracting: tocompress/dot2.txtextracting: tocompress/secuential.txtinflating: tocompress/index.html.1extracting: tocompress/file.txtextracting: tocompress/datos1inflating: tocompress/2021-02-11-Introduccion-a-Python.ipynbextracting: tocompress/datos123
!ls -lh
total 792K-rw-rw-r-- 1 wallabot wallabot 280K dic 6 00:28 2021-02-11-Introduccion-a-Python.ipynb-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 Abc-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos1-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 datos123-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot2.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 dot.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 file.txt-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:49 google2.html-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:48 google.html-rw-rw-r-- 1 wallabot wallabot 0 dic 6 00:56 index.html-rw-rw-r-- 1 wallabot wallabot 15K dic 6 01:49 index.html.1-rw-rw-r-- 1 wallabot wallabot 182 dic 6 01:06 lista.txt-rw-rw-r-- 1 wallabot wallabot 0 dic 6 01:08 secuential.txtdrwxrwxr-x 2 wallabot wallabot 4,0K dic 6 01:52 tocompress-rw-rw-r-- 1 wallabot wallabot 340K dic 6 01:53 tocompress.tar-rw-rw-r-- 1 wallabot wallabot 52K dic 6 01:53 tocompress.tar.gz-rw-rw-r-- 1 wallabot wallabot 64K dic 6 01:53 tocompress.zip
Background and Foreground Processes
Pause a Process and Send It to the Background with CTRL+Z
When we run a process in the terminal, it may not stop executing and we might want to continue using the terminal. To solve this, we can move the process to the background by pressing CTRL+z
.
For example, I can ping myself without specifying the number of attempts, so this will be running until I stop the process by pressing CTRL+C
!ping localhost
PING localhost (127.0.0.1) 56(84) bytes of data.64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.025 ms64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.027 ms64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.024 ms64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.024 ms64 bytes from localhost (127.0.0.1): icmp_seq=5 ttl=64 time=0.027 ms64 bytes from localhost (127.0.0.1): icmp_seq=6 ttl=64 time=0.036 ms^C--- localhost ping statistics ---6 packets transmitted, 6 received, 0% packet loss, time 5127msrtt min/avg/max/mdev = 0.024/0.027/0.036/0.004 ms
However, if what we want is to stop the process for a moment to continue using the terminal, we need to enter Ctrl+Z
!ping localhost
PING localhost (127.0.0.1) 56(84) bytes of data.64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.028 ms64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.020 ms64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.017 ms64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.025 ms64 bytes from localhost (127.0.0.1): icmp_seq=5 ttl=64 time=0.021 ms64 bytes from localhost (127.0.0.1): icmp_seq=6 ttl=64 time=0.055 ms^Z[1]+ Detenido ping localhost
As indicated, the process has been stopped, it is not running while I have put it in the background.
Viewing Background Processes with jobs
To see which processes are in the background, we have two commands, on one hand, we can use jobs
!jobs
jobs[1]+ Detenido ping localhost
This command gives us the process and job number, this number will be the one we need to use to bring the process to the foreground
View background processes with ps
Another command we can use is ps
(processes)
!ps
PID TTY TIME CMD16232 pts/3 00:00:00 bash17070 pts/3 00:00:00 ping18376 pts/3 00:00:00 ps
This command not only gives us information about the processes running in the background but also about all the processes running in the terminal.
It is important to emphasize that if we open a new terminal and use any of these commands, it will not give us the ping information, since we executed it in another terminal.
!ps
PID TTY TIME CMD18993 pts/2 00:00:00 bash19290 pts/2 00:00:00 ps
As we can see, jobs
does not return anything because there is no background process in this terminal and ps
only returns the information of bash (the terminal itself) and the ps command executed.
Bringing a background process to the foreground
To bring a process to the foreground, you need to use the fg
command. If you want to bring the last process that was sent to the background, simply typing fg
is enough; otherwise, you need to specify the job number.
Let's take another look at the processes we had in the background
!jobs
[1]+ Detenido ping localhost
We can bring this process to the foreground by just typing fg
or indicating the job number with fg %1
!fg %1
ping localhost64 bytes from localhost (127.0.0.1): icmp_seq=7 ttl=64 time=0.032 ms64 bytes from localhost (127.0.0.1): icmp_seq=8 ttl=64 time=0.036 ms64 bytes from localhost (127.0.0.1): icmp_seq=9 ttl=64 time=0.045 ms64 bytes from localhost (127.0.0.1): icmp_seq=10 ttl=64 time=0.035 ms64 bytes from localhost (127.0.0.1): icmp_seq=11 ttl=64 time=0.031 ms
Running a Process Directly in the Background
Let's relaunch the Firefox browser now by typing firefox
in the terminal and pressing CTRL+Z
to send it to the background.
!firefox
[GFX1-]: glxtest: VA-API test failed: failed to initialise VAAPI connection.[2022-11-29T06:16:17Z ERROR glean_core::metrics::ping] Invalid reason code startup for ping background-update^Z[1]+ Detenido firefox
As we can see, it says that the process has been stopped, so if we want to browse with Firefox now, we can't, as it is stopped.
To be able to launch Firefox and have it in the background so that it doesn't block our terminal, you need to write an &
at the end of the command
!firefox &
[1] 23663$ [GFX1-]: glxtest: VA-API test failed: failed to initialise VAAPI connection.[2022-11-29T06:19:40Z ERROR glean_core::metrics::ping] Invalid reason code startup for ping background-update$
Now we launch Firefox, it tells us its job number and stays running in the background
In fact, if we now look at the processes, we can see the state of Firefox is Running
!jobs
[1]+ Ejecutando firefox &
Terminate a background process
As we have Firefox running in the background, if we want it to terminate, we need to use kill
and the job number of the process. We'll use jobs
to see the job number of Firefox.
!jobs
[1]+ Ejecutando firefox &
Your job number is 1, so we use that number to complete the process.
!kill %1
It doesn't respond anything to us, but if we use jobs
again to see the processes in the background
!jobs
[1]+ Terminado firefox
We see that it tells us Firefox has finished, if we run jobs
again nothing will appear.
!jobs
Terminal-independent background processes
So far we have seen how to execute background processes dependent on the terminal, this means that if we send a process to the background and close the terminal, it will send a termination message to all the processes in its background and they will terminate.
But there are times when we want the process to stay in the background, be able to close the terminal, open another one, and recover that process. For this, we will use tmux
, which is a terminal multiplexer.
It is possible that it comes pre-installed, so to install it you have to enter the following
sudo apt install tmux
Once installed, we can create a new tmux
session using tmux new -s <name>
````tmux new -s session1````
This will open a new terminal for us, which is actually a tmux
session
Within it, we can launch a process, for example a ping
to ourselves
!ping localhost
PING localhost (127.0.0.1) 56(84) bytes of data.64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.036 ms64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.019 ms64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.031 ms
We can close that terminal
If we open a new one, we can see all the open tmux
sessions with the command tmux ls
!tmux ls
session1: 1 windows (created Tue Nov 29 08:15:22 2022)
And we can enter a session using the command tmux
, followed by a
(attach), -t
(tag), and the name of the session.
!tmux a -t session1
64 bytes from localhost (127.0.0.1): icmp_seq=146 ttl=64 time=0.025 ms64 bytes from localhost (127.0.0.1): icmp_seq=147 ttl=64 time=0.022 ms64 bytes from localhost (127.0.0.1): icmp_seq=148 ttl=64 time=0.026 ms64 bytes from localhost (127.0.0.1): icmp_seq=149 ttl=64 time=0.013 ms64 bytes from localhost (127.0.0.1): icmp_seq=150 ttl=64 time=0.027 ms64 bytes from localhost (127.0.0.1): icmp_seq=151 ttl=64 time=0.019 ms
As we see, we have recovered the previous ping
When we are inside a session, we can exit it (killing it) by typing CTRL+D
or typing exit
Process Management
To manage the processes of our system we have several options
Process Handler ps
As we have seen before, ps
gives us the processes that are running in our terminal. For example, we run a process in the background and see the processes with ps
!firefox &
[1] 50555
We now see the processes
!ps
PID TTY TIME CMD36660 pts/3 00:00:00 bash50555 pts/3 00:00:02 firefox50613 pts/3 00:00:00 Socket Process50635 pts/3 00:00:00 Privileged Cont50683 pts/3 00:00:00 WebExtensions50741 pts/3 00:00:00 Web Content50743 pts/3 00:00:00 Web Content50748 pts/3 00:00:00 Web Content50840 pts/3 00:00:00 ps
Once we know its PID, we can kill the process
!kill 50555
We now look at the processes
!ps
PID TTY TIME CMD36660 pts/3 00:00:00 bash51132 pts/3 00:00:00 ps
But as we have said, the downside of ps
is that it only shows the processes of its terminal
To show us all the system processes we need to add aux
terminal("ps aux", max_lines_output=10)
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMANDroot 1 0.2 0.0 169936 13172 ? Ss 23:06 0:01 /sbin/init splashroot 2 0.0 0.0 0 0 ? S 23:06 0:00 [kthreadd]root 3 0.0 0.0 0 0 ? I< 23:06 0:00 [rcu_gp]root 4 0.0 0.0 0 0 ? I< 23:06 0:00 [rcu_par_gp]root 5 0.0 0.0 0 0 ? I< 23:06 0:00 [netns]root 7 0.0 0.0 0 0 ? I< 23:06 0:00 [kworker/0:0H-events_highpri]root 9 0.0 0.0 0 0 ? I< 23:06 0:00 [kworker/0:1H-events_highpri]root 10 0.0 0.0 0 0 ? I< 23:06 0:00 [mm_percpu_wq]root 11 0.0 0.0 0 0 ? S 23:06 0:00 [rcu_tasks_rude_]...wallabot 11094 0.0 0.2 1184730916 65900 ? Sl 23:19 0:00 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=76 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=781545948 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072wallabot 11428 0.3 0.2 38136100 75812 ? Sl 23:21 0:00 /usr/share/code/code --ms-enable-electron-run-as-node /usr/share/code/resources/app/extensions/markdown-language-features/server/dist/node/main --node-ipc --clientProcessId=8508root 11508 0.0 0.0 0 0 ? I 23:21 0:00 [kworker/4:1-events]wallabot 11683 0.0 0.0 14192 3380 ? R 23:22 0:00 ps aux
Now, if what I want is to search only for the processes that my user is running, I can do it by creating a pipe
and searching with grep
!ps aux | grep wallabot
avahi 802 0.0 0.0 8536 3912 ? Ss 23:06 0:00 avahi-daemon: running [wallabot.local]wallabot 1153 0.0 0.0 19856 10624 ? Ss 23:06 0:00 /lib/systemd/systemd --userwallabot 1154 0.0 0.0 170004 3680 ? S 23:06 0:00 (sd-pam)wallabot 1159 0.1 0.0 2569384 22808 ? S<sl 23:06 0:01 /usr/bin/pulseaudio --daemonize=no --log-target=journalwallabot 1161 0.1 0.1 591424 37248 ? SNsl 23:06 0:02 /usr/libexec/tracker-miner-fswallabot 1164 0.0 0.0 390744 8664 ? SLl 23:06 0:00 /usr/bin/gnome-keyring-daemon --daemonize --loginwallabot 1168 0.0 0.0 166804 6616 tty2 Ssl+ 23:06 0:00 /usr/lib/gdm3/gdm-x-session --run-script env GNOME_SHELL_SESSION_MODE=ubuntu /usr/bin/gnome-session --systemd --session=ubuntuwallabot 1173 0.0 0.0 8904 6012 ? Ss 23:06 0:00 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-onlywallabot 1181 0.0 0.0 242628 7884 ? Ssl 23:06 0:00 /usr/libexec/gvfsdwallabot 1196 0.0 0.0 378348 5544 ? Sl 23:06 0:00 /usr/libexec/gvfsd-fuse /run/user/1000/gvfs -f -o big_writeswallabot 1203 0.0 0.0 316896 9540 ? Ssl 23:06 0:00 /usr/libexec/gvfs-udisks2-volume-monitorwallabot 1209 0.0 0.0 319540 8920 ? Ssl 23:06 0:00 /usr/libexec/gvfs-afc-volume-monitorwallabot 1215 0.0 0.0 238612 5476 ? Ssl 23:06 0:00 /usr/libexec/gvfs-mtp-volume-monitorwallabot 1220 0.0 0.0 239456 6988 ? Ssl 23:06 0:00 /usr/libexec/gvfs-goa-volume-monitorwallabot 1224 0.0 0.2 707176 69244 ? SLl 23:06 0:00 /usr/libexec/goa-daemonwallabot 1231 0.0 0.0 317692 9068 ? Sl 23:06 0:00 /usr/libexec/goa-identity-servicewallabot 1237 0.0 0.0 240888 6244 ? Ssl 23:06 0:00 /usr/libexec/gvfs-gphoto2-volume-monitorwallabot 1308 0.0 0.0 190872 13688 tty2 Sl+ 23:06 0:00 /usr/libexec/gnome-session-binary --systemd --systemd --session=ubuntuwallabot 1375 0.0 0.0 6040 452 ? Ss 23:06 0:00 /usr/bin/ssh-agent /usr/bin/im-launch env GNOME_SHELL_SESSION_MODE=ubuntu /usr/bin/gnome-session --systemd --session=ubuntuwallabot 1394 0.0 0.0 305428 6572 ? Ssl 23:06 0:00 /usr/libexec/at-spi-bus-launcherwallabot 1399 0.0 0.0 7380 4240 ? S 23:06 0:00 /usr/bin/dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofork --print-address 3wallabot 1405 0.0 0.0 92852 4228 ? Ssl 23:06 0:00 /usr/libexec/gnome-session-ctl --monitorwallabot 1412 0.0 0.0 414004 16532 ? Ssl 23:06 0:00 /usr/libexec/gnome-session-binary --systemd-service --session=ubuntuwallabot 1426 3.7 1.2 5576364 425284 ? Rsl 23:06 0:41 /usr/bin/gnome-shellwallabot 1476 0.0 0.0 387612 8436 ? Sl 23:06 0:00 ibus-daemon --panel disable --ximwallabot 1480 0.0 0.0 165628 7060 ? Sl 23:06 0:00 /usr/libexec/ibus-memconfwallabot 1481 0.0 0.0 276012 29224 ? Sl 23:06 0:00 /usr/libexec/ibus-extension-gtk3wallabot 1483 0.0 0.0 196832 24676 ? Sl 23:06 0:00 /usr/libexec/ibus-x11 --kill-daemonwallabot 1486 0.0 0.0 239400 7244 ? Sl 23:06 0:00 /usr/libexec/ibus-portalwallabot 1498 0.0 0.0 162916 6508 ? Sl 23:06 0:00 /usr/libexec/at-spi2-registryd --use-gnome-sessionwallabot 1502 0.0 0.0 238512 5936 ? Ssl 23:06 0:00 /usr/libexec/xdg-permission-storewallabot 1504 0.0 0.0 862476 24084 ? Sl 23:06 0:00 /usr/libexec/gnome-shell-calendar-serverwallabot 1513 0.0 0.0 618416 32636 ? Ssl 23:06 0:00 /usr/libexec/evolution-source-registrywallabot 1521 0.0 0.0 156476 5716 ? Sl 23:06 0:00 /usr/libexec/dconf-servicewallabot 1524 0.0 0.0 165712 7076 ? Ssl 23:06 0:00 /usr/libexec/gvfsd-metadatawallabot 1535 0.0 0.1 1680828 49932 ? Ssl 23:06 0:00 /usr/libexec/evolution-calendar-factorywallabot 1551 0.0 0.0 676260 30636 ? Ssl 23:06 0:00 /usr/libexec/evolution-addressbook-factorywallabot 1585 0.0 0.0 2933212 27180 ? Sl 23:06 0:00 /usr/bin/gjs /usr/share/gnome-shell/org.gnome.Shell.Notificationswallabot 1597 0.0 0.0 316920 7980 ? Sl 23:06 0:00 /usr/libexec/gvfsd-trash --spawner :1.4 /org/gtk/gvfs/exec_spaw/0wallabot 1612 0.0 0.0 312652 6796 ? Ssl 23:06 0:00 /usr/libexec/gsd-a11y-settingswallabot 1613 0.0 0.0 587548 27164 ? Ssl 23:06 0:00 /usr/libexec/gsd-colorwallabot 1614 0.0 0.0 376604 16508 ? Ssl 23:06 0:00 /usr/libexec/gsd-datetimewallabot 1616 0.0 0.0 314840 7876 ? Ssl 23:06 0:00 /usr/libexec/gsd-housekeepingwallabot 1619 0.0 0.0 344796 25276 ? Ssl 23:06 0:00 /usr/libexec/gsd-keyboardwallabot 1623 0.0 0.0 900140 28012 ? Ssl 23:06 0:00 /usr/libexec/gsd-media-keyswallabot 1627 0.0 0.0 418936 25736 ? Ssl 23:06 0:00 /usr/libexec/gsd-powerwallabot 1629 0.0 0.0 251196 11384 ? Ssl 23:06 0:00 /usr/libexec/gsd-print-notificationswallabot 1630 0.0 0.0 459940 6088 ? Ssl 23:06 0:00 /usr/libexec/gsd-rfkillwallabot 1632 0.0 0.0 238348 6344 ? Ssl 23:06 0:00 /usr/libexec/gsd-screensaver-proxywallabot 1633 0.0 0.0 467776 11088 ? Ssl 23:06 0:00 /usr/libexec/gsd-sharingwallabot 1634 0.0 0.0 318156 10452 ? Ssl 23:06 0:00 /usr/libexec/gsd-smartcardwallabot 1636 0.0 0.0 322344 9400 ? Ssl 23:06 0:00 /usr/libexec/gsd-soundwallabot 1637 0.0 0.0 461692 7252 ? Ssl 23:06 0:00 /usr/libexec/gsd-usb-protectionwallabot 1640 0.0 0.0 344332 24372 ? Ssl 23:06 0:00 /usr/libexec/gsd-wacomwallabot 1643 0.0 0.0 390820 8260 ? Ssl 23:06 0:00 /usr/libexec/gsd-wwanwallabot 1644 0.0 0.0 345572 25980 ? Ssl 23:06 0:00 /usr/libexec/gsd-xsettingswallabot 1649 0.0 0.2 1227284 75100 ? Sl 23:06 0:00 /usr/libexec/evolution-data-server/evolution-alarm-notifywallabot 1673 0.0 0.1 413288 60304 ? Sl 23:06 0:00 /usr/bin/python3 /usr/bin/solaarwallabot 1692 0.0 0.0 231804 5972 ? Sl 23:06 0:00 /usr/libexec/gsd-disk-utility-notifywallabot 1730 0.0 0.0 165620 7028 ? Sl 23:06 0:00 /usr/libexec/ibus-engine-simplewallabot 1739 0.0 0.0 438456 19104 ? Sl 23:06 0:00 /usr/libexec/gvfsd-http --spawner :1.4 /org/gtk/gvfs/exec_spaw/1wallabot 1748 0.4 0.6 1242548 217144 ? Sl 23:06 0:04 /snap/snap-store/599/usr/bin/snap-store --gapplication-servicewallabot 1760 0.0 0.0 345020 15016 ? Sl 23:06 0:00 /usr/libexec/gsd-printerwallabot 1797 0.0 0.0 608052 6664 ? Ssl 23:06 0:00 /usr/libexec/xdg-document-portalwallabot 2170 0.0 0.0 612960 11060 ? Ssl 23:06 0:00 /usr/libexec/xdg-desktop-portalwallabot 2174 0.0 0.0 493648 26488 ? Ssl 23:06 0:00 /usr/libexec/xdg-desktop-portal-gtkwallabot 4839 0.0 0.0 420020 28340 ? Sl 23:07 0:00 update-notifierwallabot 5019 0.0 0.0 436628 21644 ? Sl 23:08 0:00 /usr/libexec/gvfsd-google --spawner :1.4 /org/gtk/gvfs/exec_spaw/2wallabot 5072 3.2 1.1 34219664 391492 ? SLl 23:08 0:32 /opt/google/chrome/chromewallabot 5077 0.0 0.0 10844 580 ? S 23:08 0:00 catwallabot 5078 0.0 0.0 10844 516 ? S 23:08 0:00 catwallabot 5080 0.0 0.0 33576132 3140 ? Sl 23:08 0:00 /opt/google/chrome/chrome_crashpad_handler --monitor-self --monitor-self-annotation=ptype=crashpad-handler --database=/home/wallabot/.config/google-chrome/Crash Reports --url=https://clients2.google.com/cr/report --annotation=channel= --annotation=lsb-release=Ubuntu 20.04.5 LTS --annotation=plat=Linux --annotation=prod=Chrome_Linux --annotation=ver=108.0.5359.71 --initial-client-fd=5 --shared-client-connectionwallabot 5082 0.0 0.0 33567920 2952 ? Sl 23:08 0:00 /opt/google/chrome/chrome_crashpad_handler --no-periodic-tasks --monitor-self-annotation=ptype=crashpad-handler --database=/home/wallabot/.config/google-chrome/Crash Reports --url=https://clients2.google.com/cr/report --annotation=channel= --annotation=lsb-release=Ubuntu 20.04.5 LTS --annotation=plat=Linux --annotation=prod=Chrome_Linux --annotation=ver=108.0.5359.71 --initial-client-fd=4 --shared-client-connectionwallabot 5088 0.0 0.1 33854440 59168 ? S 23:08 0:00 /opt/google/chrome/chrome --type=zygote --no-zygote-sandbox --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enablewallabot 5089 0.0 0.1 33854436 59068 ? S 23:08 0:00 /opt/google/chrome/chrome --type=zygote --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enablewallabot 5090 0.0 0.0 33568428 5024 ? S 23:08 0:00 /opt/google/chrome/nacl_helperwallabot 5093 0.0 0.0 33854460 16384 ? S 23:08 0:00 /opt/google/chrome/chrome --type=zygote --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enablewallabot 5123 6.0 0.8 34211392 285560 ? Sl 23:08 1:00 /opt/google/chrome/chrome --type=gpu-process --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --gpu-preferences=WAAAAAAAAAAgAAAIAAAAAAAAAAAAAAAAAABgAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAIAAAAAAAAAABAAAAAAAAAAgAAAAAAAAACAAAAAAAAAAIAAAAAAAAAA== --shared-files --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072wallabot 5124 0.6 0.3 33918264 119584 ? Sl 23:08 0:06 /opt/google/chrome/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=es --service-sandbox-type=none --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072wallabot 5136 0.0 0.1 33895840 52500 ? Sl 23:08 0:00 /opt/google/chrome/chrome --type=utility --utility-sub-type=storage.mojom.StorageService --lang=es --service-sandbox-type=utility --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072wallabot 5155 0.1 0.4 1184797648 132208 ? Sl 23:08 0:01 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --extension-process --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=5 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=121160165 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072wallabot 5171 4.5 0.6 1188020280 229028 ? Sl 23:08 0:44 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=27 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=121254783 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072wallabot 5228 0.0 0.2 1184772236 89352 ? Sl 23:08 0:00 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --extension-process --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=6 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=121309474 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072wallabot 5247 0.0 0.2 1184788292 86368 ? Sl 23:08 0:00 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --extension-process --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=7 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=121342017 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072wallabot 5274 0.3 0.4 1184796488 155056 ? Sl 23:08 0:03 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --extension-process --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=8 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=121354013 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072wallabot 5294 0.1 0.3 1184797648 123536 ? Sl 23:08 0:01 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --extension-process --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=9 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=121366454 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072wallabot 5300 0.0 0.2 1184771900 88048 ? Sl 23:08 0:00 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --extension-process --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=10 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=121370528 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072wallabot 5325 0.0 0.1 34023608 34500 ? S 23:08 0:00 /opt/google/chrome/chrome --type=brokerwallabot 5343 0.0 0.3 1184780096 98820 ? Sl 23:08 0:00 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --extension-process --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=45 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=121454617 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072wallabot 5381 0.0 0.0 197896 29728 ? Sl 23:08 0:00 /usr/bin/python3 /usr/bin/chrome-gnome-shell chrome-extension://gphhapmejobijbbhgpjhcjognlahblep/wallabot 5467 0.8 0.5 1185857508 194536 ? Sl 23:08 0:08 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=48 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=122388284 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072wallabot 5547 0.0 0.2 34155852 77000 ? Sl 23:08 0:00 /opt/google/chrome/chrome --type=utility --utility-sub-type=audio.mojom.AudioService --lang=es --service-sandbox-type=none --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072wallabot 5584 0.0 0.3 1184798704 126008 ? Sl 23:08 0:00 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=40 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=127275168 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072wallabot 5590 0.1 0.4 1184799064 148824 ? Sl 23:08 0:01 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=28 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=127276723 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072wallabot 5592 8.3 0.8 1187976688 283688 ? Sl 23:08 1:22 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=30 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=127278497 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072wallabot 5636 0.0 0.3 1184805876 122780 ? Sl 23:08 0:00 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=51 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=127293028 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072wallabot 5753 0.0 0.3 1184796632 104664 ? Sl 23:08 0:00 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=52 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=129692647 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072wallabot 5788 3.0 0.8 1185884504 276332 ? Sl 23:08 0:29 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=19 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=130329055 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072wallabot 5828 1.9 0.9 1184827212 309156 ? Sl 23:08 0:19 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=22 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=131345480 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072wallabot 5846 0.6 0.6 1184844960 207484 ? Sl 23:08 0:06 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=36 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=131537892 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072wallabot 6066 0.5 0.6 1184828968 220584 ? Sl 23:08 0:05 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=35 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=135569943 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072wallabot 6120 0.0 0.0 43992 6552 ? Ss 23:08 0:00 /usr/lib/bluetooth/obexdwallabot 6134 0.4 0.7 1184856952 230428 ? Sl 23:08 0:04 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=34 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=136358048 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072wallabot 6524 0.4 0.6 1184857312 226988 ? Sl 23:08 0:04 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=33 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=139865567 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072wallabot 8034 0.0 0.1 1064452 54580 ? Sl 23:10 0:00 /usr/bin/gnome-calendar --gapplication-servicewallabot 8158 0.7 0.7 3981248 239132 ? Sl 23:10 0:07 /snap/spotify/60/usr/share/spotify/spotifywallabot 8242 0.0 0.2 647244 77376 ? S 23:10 0:00 /snap/spotify/60/usr/share/spotify/spotify --type=zygote --no-zygote-sandbox --no-sandbox --log-severity=disable --user-agent-product=Chrome/99.0.4844.84 Spotify/1.1.84.716 --lang=en --user-data-dir=/home/wallabot/snap/spotify/60/.config/spotify/User Data --log-file=/snap/spotify/60/usr/share/spotify/debug.logwallabot 8243 0.0 0.2 647244 77100 ? S 23:10 0:00 /snap/spotify/60/usr/share/spotify/spotify --type=zygote --no-sandbox --log-severity=disable --user-agent-product=Chrome/99.0.4844.84 Spotify/1.1.84.716 --lang=en --user-data-dir=/home/wallabot/snap/spotify/60/.config/spotify/User Data --log-file=/snap/spotify/60/usr/share/spotify/debug.logwallabot 8259 0.1 0.3 2041284 114252 ? Sl 23:10 0:01 /snap/spotify/60/usr/share/spotify/spotify --type=gpu-process --no-sandbox --log-severity=disable --user-agent-product=Chrome/99.0.4844.84 Spotify/1.1.84.716 --lang=en --user-data-dir=/home/wallabot/snap/spotify/60/.config/spotify/User Data --gpu-preferences=UAAAAAAAAAAgAAAIAAAAAAAAAAAAAAAAAABgAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAABgAAAAAAAAAGAAAAAAAAAAIAAAAAAAAAAgAAAAAAAAACAAAAAAAAAA= --log-file=/snap/spotify/60/usr/share/spotify/debug.log --shared-files --field-trial-handle=0,i,8625640855432007833,7773453088797360000,131072wallabot 8274 0.0 0.1 868700 34104 ? Sl 23:10 0:00 /snap/spotify/60/usr/share/spotify/spotify --type=utility --utility-sub-type=storage.mojom.StorageService --lang=en-US --service-sandbox-type=utility --no-sandbox --log-severity=disable --user-agent-product=Chrome/99.0.4844.84 Spotify/1.1.84.716 --lang=en --user-data-dir=/home/wallabot/snap/spotify/60/.config/spotify/User Data --log-file=/snap/spotify/60/usr/share/spotify/debug.log --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,8625640855432007833,7773453088797360000,131072wallabot 8279 0.0 0.3 1148480 99680 ? Sl 23:10 0:00 /snap/spotify/60/usr/share/spotify/spotify --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --log-severity=disable --user-agent-product=Chrome/99.0.4844.84 Spotify/1.1.84.716 --lang=en --user-data-dir=/home/wallabot/snap/spotify/60/.config/spotify/User Data --log-file=/snap/spotify/60/usr/share/spotify/debug.log --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,8625640855432007833,7773453088797360000,131072wallabot 8319 0.5 0.5 31646352 187140 ? Sl 23:10 0:05 /snap/spotify/60/usr/share/spotify/spotify --type=renderer --log-severity=disable --user-agent-product=Chrome/99.0.4844.84 Spotify/1.1.84.716 --disable-spell-checking --user-data-dir=/home/wallabot/snap/spotify/60/.config/spotify/User Data --no-sandbox --log-file=/snap/spotify/60/usr/share/spotify/debug.log --lang=en-US --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=5 --launch-time-ticks=210215195 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,8625640855432007833,7773453088797360000,131072wallabot 8377 0.5 0.4 38371288 161752 ? SLl 23:10 0:05 /usr/share/code/code --unity-launch --enable-crashpadwallabot 8391 0.0 0.1 33775112 48516 ? S 23:10 0:00 /usr/share/code/code --type=zygote --no-zygote-sandbox --enable-crashpad --enable-crashpadwallabot 8392 0.0 0.1 33775096 48304 ? S 23:10 0:00 /usr/share/code/code --type=zygote --enable-crashpad --enable-crashpadwallabot 8394 0.0 0.0 33775124 12448 ? S 23:10 0:00 /usr/share/code/code --type=zygote --enable-crashpad --enable-crashpadwallabot 8407 0.0 0.0 33575984 3384 ? Sl 23:10 0:00 /usr/share/code/chrome_crashpad_handler --monitor-self-annotation=ptype=crashpad-handler --no-rate-limit --database=/home/wallabot/.config/Code/Crashpad --url=appcenter://code?aid=fba07a4d-84bd-4fc8-a125-9640fc8ce171&uid=e1be826f-73fb-46c2-a439-9bb52643ccc1&iid=e1be826f-73fb-46c2-a439-9bb52643ccc1&sid=e1be826f-73fb-46c2-a439-9bb52643ccc1 --annotation=_companyName=Microsoft --annotation=_productName=VSCode --annotation=_version=1.73.1 --annotation=lsb-release=Ubuntu 20.04.5 LTS --annotation=plat=Linux --annotation=prod=Electron --annotation=ver=19.0.17 --initial-client-fd=43 --shared-client-connectionwallabot 8425 1.5 0.5 33985512 195464 ? Sl 23:10 0:14 /usr/share/code/code --type=gpu-process --enable-crashpad --crashpad-handler-pid=8407 --enable-crash-reporter=7a83c65f-14e6-4aa2-9df9-71fc458479f5,no_channel --user-data-dir=/home/wallabot/.config/Code --gpu-preferences=WAAAAAAAAAAgAAAIAAAAAAAAAAAAAAAAAABgAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAIAAAAAAAAAABAAAAAAAAAAgAAAAAAAAACAAAAAAAAAAIAAAAAAAAAA== --shared-files --field-trial-handle=0,i,8890103601020485358,15523745040863579529,131072 --disable-features=CalculateNativeWinOcclusion,SpareRendererForSitePerProcesswallabot 8429 0.0 0.2 33840968 66520 ? Sl 23:10 0:00 /usr/share/code/code --type=utility --utility-sub-type=network.mojom.NetworkService --lang=es --service-sandbox-type=none --enable-crashpad --crashpad-handler-pid=8407 --enable-crash-reporter=7a83c65f-14e6-4aa2-9df9-71fc458479f5,no_channel --user-data-dir=/home/wallabot/.config/Code --standard-schemes=vscode-webview,vscode-file --secure-schemes=vscode-webview,vscode-file --bypasscsp-schemes --cors-schemes=vscode-webview,vscode-file --fetch-schemes=vscode-webview,vscode-file --service-worker-schemes=vscode-webview --streaming-schemes --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,8890103601020485358,15523745040863579529,131072 --disable-features=CalculateNativeWinOcclusion,SpareRendererForSitePerProcess --enable-crashpadwallabot 8439 0.0 0.0 33851528 23624 ? S 23:10 0:00 /usr/share/code/code --type=brokerwallabot 8449 8.5 1.1 61424852 390980 ? Sl 23:10 1:16 /usr/share/code/code --type=renderer --enable-crashpad --crashpad-handler-pid=8407 --enable-crash-reporter=7a83c65f-14e6-4aa2-9df9-71fc458479f5,no_channel --user-data-dir=/home/wallabot/.config/Code --standard-schemes=vscode-webview,vscode-file --secure-schemes=vscode-webview,vscode-file --bypasscsp-schemes --cors-schemes=vscode-webview,vscode-file --fetch-schemes=vscode-webview,vscode-file --service-worker-schemes=vscode-webview --streaming-schemes --app-path=/usr/share/code/resources/app --no-sandbox --no-zygote --enable-blink-features=HighlightAPI --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=4 --launch-time-ticks=217445761 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,8890103601020485358,15523745040863579529,131072 --disable-features=CalculateNativeWinOcclusion,SpareRendererForSitePerProcess --vscode-window-config=vscode:13905479-a7dd-4e24-9b88-cf580c42a25d --enable-crashpadwallabot 8508 1.4 0.8 59175788 268364 ? Sl 23:10 0:12 /usr/share/code/code --ms-enable-electron-run-as-node --inspect-port=0 /usr/share/code/resources/app/out/bootstrap-fork --type=extensionHost --skipWorkspaceStorageLockwallabot 8566 0.1 0.2 38136100 81468 ? Sl 23:10 0:01 /usr/share/code/code --ms-enable-electron-run-as-node /home/wallabot/.vscode/extensions/kisstkondoros.vscode-gutter-preview-0.30.0/dist/server.js --node-ipc --clientProcessId=8508wallabot 8575 0.6 0.4 46670736 139408 ? Sl 23:10 0:05 /usr/share/code/code --type=renderer --enable-crashpad --crashpad-handler-pid=8407 --enable-crash-reporter=7a83c65f-14e6-4aa2-9df9-71fc458479f5,no_channel --user-data-dir=/home/wallabot/.config/Code --standard-schemes=vscode-webview,vscode-file --secure-schemes=vscode-webview,vscode-file --bypasscsp-schemes --cors-schemes=vscode-webview,vscode-file --fetch-schemes=vscode-webview,vscode-file --service-worker-schemes=vscode-webview --streaming-schemes --app-path=/usr/share/code/resources/app --no-sandbox --no-zygote --node-integration-in-worker --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=5 --launch-time-ticks=219833707 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,8890103601020485358,15523745040863579529,131072 --disable-features=CalculateNativeWinOcclusion,SpareRendererForSitePerProcess --vscode-window-config=vscode:be96c98d-9154-449a-b127-c0211495f4ef --vscode-window-kind=shared-process --enable-crashpadwallabot 8593 0.0 0.2 38177772 78236 ? Sl 23:10 0:00 /usr/share/code/code --ms-enable-electron-run-as-node /usr/share/code/resources/app/out/bootstrap-fork --type=ptyHost --logsPath /home/wallabot/.config/Code/logs/20221202T231016wallabot 8632 0.0 0.2 38185752 94568 ? Sl 23:10 0:00 /usr/share/code/code --ms-enable-electron-run-as-node /usr/share/code/resources/app/out/bootstrap-fork --type=fileWatcherwallabot 8656 0.6 0.5 42430176 182480 ? Sl 23:10 0:05 /usr/share/code/code --type=renderer --enable-crashpad --crashpad-handler-pid=8407 --enable-crash-reporter=7a83c65f-14e6-4aa2-9df9-71fc458479f5,no_channel --user-data-dir=/home/wallabot/.config/Code --standard-schemes=vscode-webview,vscode-file --secure-schemes=vscode-webview,vscode-file --bypasscsp-schemes --cors-schemes=vscode-webview,vscode-file --fetch-schemes=vscode-webview,vscode-file --service-worker-schemes=vscode-webview --streaming-schemes --app-path=/usr/share/code/resources/app --enable-sandbox --enable-blink-features=HighlightAPI --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=6 --launch-time-ticks=220495638 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,8890103601020485358,15523745040863579529,131072 --disable-features=CalculateNativeWinOcclusion,SpareRendererForSitePerProcess --vscode-window-config=vscode:13905479-a7dd-4e24-9b88-cf580c42a25dwallabot 8716 1.4 0.5 38140204 169984 ? Sl 23:10 0:12 /usr/share/code/code --ms-enable-electron-run-as-node /home/wallabot/.vscode/extensions/ms-python.vscode-pylance-2022.11.40/dist/server.bundle.js --cancellationReceive=file:3646d9eb9edaa1bd82425403564df0006a57a0df01 --node-ipc --clientProcessId=8508wallabot 8744 0.1 0.3 38140204 104772 ? Sl 23:10 0:01 /usr/share/code/code --ms-enable-electron-run-as-node /home/wallabot/.vscode/extensions/ms-python.vscode-pylance-2022.11.40/dist/server.bundle.js --cancellationReceive=file:f832ffa59d80abd5b35e8851e94332c285b2c3f9bb --node-ipc --clientProcessId=8508wallabot 8781 0.1 0.2 480956 77852 ? Sl 23:10 0:01 /home/wallabot/anaconda3/bin/python -m ipykernel_launcher --ip=127.0.0.1 --stdin=9003 --control=9001 --hb=9000 --Session.signature_scheme="hmac-sha256" --Session.key=b"c6d890f5-5fb6-41d8-9a66-32d953505406" --shell=9002 --transport="tcp" --iopub=9004 --f=/home/wallabot/.local/share/jupyter/runtime/kernel-v2-8508kHWtNFMgKsBL.jsonwallabot 8788 0.0 0.0 116624 29744 ? Sl 23:10 0:00 /bin/python3 /home/wallabot/.vscode/extensions/ms-python.isort-2022.8.0/bundled/tool/server.pywallabot 8898 0.6 0.4 38144304 146508 ? Sl 23:10 0:05 /usr/share/code/code --ms-enable-electron-run-as-node /home/wallabot/.vscode/extensions/ms-python.vscode-pylance-2022.11.40/dist/server.bundle.js --cancellationReceive=file:f57d6ea9bb6b4fa6ae2a6938661d2443c126a7b3df --node-ipc --clientProcessId=8508wallabot 8911 0.0 0.2 38136100 70604 ? Sl 23:10 0:00 /usr/share/code/code --ms-enable-electron-run-as-node /usr/share/code/resources/app/extensions/json-language-features/server/dist/node/jsonServerMain --node-ipc --clientProcessId=8508wallabot 8932 0.0 0.0 13648 5412 pts/0 Ss+ 23:10 0:00 /usr/bin/bash --init-file /usr/share/code/resources/app/out/vs/workbench/contrib/terminal/browser/media/shellIntegration-bash.shwallabot 9112 0.0 0.1 816596 50392 ? Ssl 23:10 0:00 /usr/libexec/gnome-terminal-serverwallabot 9120 0.0 0.0 13628 5212 pts/1 Ss+ 23:10 0:00 bashwallabot 10927 0.0 0.3 1184807108 117996 ? Sl 23:19 0:00 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=72 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=743183717 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072wallabot 11428 0.1 0.2 38136100 74884 ? Sl 23:21 0:00 /usr/share/code/code --ms-enable-electron-run-as-node /usr/share/code/resources/app/extensions/markdown-language-features/server/dist/node/main --node-ipc --clientProcessId=8508wallabot 12009 0.0 0.2 1184730916 65832 ? Sl 23:24 0:00 /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=5080 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --lang=es --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=80 --time-ticks-at-unix-epoch=-1670018798736448 --launch-time-ticks=1081580044 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,18391862866948577032,30807856093711604,131072wallabot 12109 0.0 0.0 2616 596 pts/2 Ss+ 23:25 0:00 /usr/bin/sh -c ps aux | grep wallabotwallabot 12110 0.0 0.0 14192 3560 pts/2 R+ 23:25 0:00 ps auxwallabot 12111 0.0 0.0 11668 660 pts/2 S+ 23:25 0:00 grep wallabot
Process Manager top
With top
we can see all the processes of the operating system. It will show the information with less
, so, as explained before, when you want to stop top
, entering q
will stop it.
!top
top - 09:31:32 up 3:21, 1 user, load average: 2,42, 2,79, 2,48Tareas: 382 total, 1 ejecutar, 381 hibernar, 0 detener, 0 zombie%Cpu(s): 14,2 usuario, 1,5 sist, 0,0 adecuado, 84,3 inact, 0,0 en espera, 0,MiB Mem : 32006,4 total, 20281,8 libre, 6229,0 usado, 5495,6 búfer/cachéMiB Intercambio: 2048,0 total, 2048,0 libre, 0,0 usado. 24979,1 disponPID USUARIO PR NI VIRT RES SHR S %CPU %MEM HORA+ ORDEN10192 wallabot 20 0 3347636 388848 84140 S 137,5 1,2 282:24.59 python44161 wallabot 20 0 30,2g 217208 100148 S 12,5 0,7 0:40.92 spotify76 root 20 0 0 0 0 S 6,2 0,0 0:00.12 ksoftir+1105 root -51 0 0 0 0 S 6,2 0,0 2:54.29 irq/125+43990 wallabot 20 0 3998836 246260 145800 S 6,2 0,8 0:53.69 spotify44101 wallabot 20 0 1995108 130316 89848 S 6,2 0,4 0:08.34 spotify51510 wallabot 20 0 14876 4088 3288 R 6,2 0,0 0:00.01 top1 root 20 0 169736 13188 8380 S 0,0 0,0 0:01.51 systemd2 root 20 0 0 0 0 S 0,0 0,0 0:00.00 kthreadd3 root 0 -20 0 0 0 I 0,0 0,0 0:00.00 rcu_gp4 root 0 -20 0 0 0 I 0,0 0,0 0:00.00 rcu_par+5 root 0 -20 0 0 0 I 0,0 0,0 0:00.00 netns7 root 0 -20 0 0 0 I 0,0 0,0 0:00.00 kworker+9 root 0 -20 0 0 0 I 0,0 0,0 0:00.03 kworker+10 root 0 -20 0 0 0 I 0,0 0,0 0:00.00 mm_perc+11 root 20 0 0 0 0 S 0,0 0,0 0:00.00 rcu_tas+12 root 20 0 0 0 0 S 0,0 0,0 0:00.00 rcu_tas+
As you can see, PID
44161 is Spotify which I am currently using to play music, but we didn't see it with ps
.
Just like before, if we want to kill a process we need to enter kill
and its PID
.
The good thing about top is that it gives us many more utilities; if we press h
it will display help.
!h
Help for Interactive Commands - procps-ng 3.3.16Window 1:Def: Cumulative mode Apagado. System: Delay 3,0 secs; Secure mode ApagZ,B,E,e Global: 'Z' colors; 'B' bold; 'E'/'e' summary/task memory scalel,t,m Toggle Summary: 'l' load avg; 't' task/cpu stats; 'm' memory info0,1,2,3,I Toggle: '0' zeros; '1/2/3' cpus or numa node views; 'I' Irix modef,F,X Fields: 'f'/'F' add/remove/order/sort; 'X' increase fixed-widthL,&,<,> . Locate: 'L'/'&' find/again; Move sort column: '<'/'>' left/rightR,H,J,C . Toggle: 'R' Sort; 'H' Threads; 'J' Num justify; 'C' Coordinatesc,i,S,j . Toggle: 'c' Cmd name/line; 'i' Idle; 'S' Time; 'j' Str justifyx,y . Toggle highlights: 'x' sort field; 'y' running tasksz,b . Toggle: 'z' color/mono; 'b' bold/reverse (only if 'x' or 'y')u,U,o,O . Filter by: 'u'/'U' effective/any user; 'o'/'O' other criterian,#,^O . Set: 'n'/'#' max tasks displayed; Show: Ctrl+'O' other filter(s)V,v . Toggle: 'V' forest view; 'v' hide/show forest view childrenk,r Gestiona tareas: «k» detener; «r» reiniciard o s Establece intervalo de actualizaciónW,Y Write configuration file 'W'; Inspect other output 'Y'q Quit( commands shown with '.' require a visible task display window )Press 'h' or '?' for help with Windows,Type 'q' or <Esc> to continue
To exit, press ESC
or q
As shown in the help, if u
is entered we can filter by user, I enter my user (wallabot) and I can see only my processes
!u
top - 09:35:57 up 3:25, 1 user, load average: 1,02, 2,27, 2,39Tareas: 378 total, 1 ejecutar, 377 hibernar, 0 detener, 0 zombie%Cpu(s): 13,4 usuario, 0,4 sist, 0,0 adecuado, 86,1 inact, 0,1 en espera, 0,MiB Mem : 32006,4 total, 20288,0 libre, 6212,0 usado, 5506,4 búfer/cachéMiB Intercambio: 2048,0 total, 2048,0 libre, 0,0 usado. 24989,1 disponPID USUARIO PR NI VIRT RES SHR S %CPU %MEM HORA+ ORDEN10192 wallabot 20 0 3347636 388848 84140 S 148,2 1,2 288:46.50 python43990 wallabot 20 0 3998836 246552 146092 S 2,7 0,8 0:59.55 spotify1384 wallabot 20 0 4909848 453700 133164 S 1,7 1,4 11:14.02 gnome-s+1119 wallabot 9 -11 3093876 24504 17836 S 1,3 0,1 0:48.99 pulseau+32462 wallabot 20 0 1134,0g 643412 128632 S 1,3 2,0 7:39.91 chrome44161 wallabot 20 0 30,2g 217112 100488 S 1,3 0,7 0:44.87 spotify10135 wallabot 20 0 826220 58164 41648 S 1,0 0,2 0:14.56 gnome-t+6635 wallabot 20 0 33,0g 647936 436252 S 0,3 2,0 4:01.80 chrome6679 wallabot 20 0 32,4g 125564 94016 S 0,3 0,4 0:52.19 chrome8010 wallabot 20 0 1130,9g 232800 116092 S 0,3 0,7 0:13.70 chrome44101 wallabot 20 0 1995108 130444 89916 S 0,3 0,4 0:09.19 spotify1113 wallabot 20 0 19880 10528 8096 S 0,0 0,0 0:00.38 systemd1114 wallabot 20 0 169792 3636 12 S 0,0 0,0 0:00.00 (sd-pam)1121 wallabot 39 19 591436 37256 16676 S 0,0 0,1 0:03.19 tracker+1124 wallabot 20 0 390740 8688 7416 S 0,0 0,0 0:00.45 gnome-k+1128 wallabot 20 0 166804 6596 5956 S 0,0 0,0 0:00.00 gdm-x-s+1134 wallabot 20 0 9152 6144 3796 S 0,0 0,0 0:01.81 dbus-da+
Another way to look at this to be able to filter by user would be to create a pipeline and use grep
!top | grep wallabot
1440 wallabot 20 0 4684708 505432 118024 S 6,7 1,5 2:05.92 gnome-s+25326 wallabot 20 0 1133,0g 527912 123732 S 1,7 1,6 1:31.73 chrome1440 wallabot 20 0 4684708 505476 118024 S 1,3 1,5 2:05.96 gnome-s+6199 wallabot 20 0 1131,0g 266068 116164 S 0,3 0,8 0:15.23 chrome17606 wallabot 20 0 818228 52096 39488 S 0,3 0,2 0:02.59 gnome-t+34284 wallabot 20 0 14876 4376 3308 R 0,3 0,0 0:00.02 top
Process Manager htop
It is similar to top
but more powerful
You probably don't have it installed, so to install it enter the command
``````markdown
sudo apt install htop
o
````sudo snap install htop`
Process Manager glances
It is similar to top
but more powerful
You probably don't have it installed, so to install it enter the command
```sudo apt install glances```
RAM Memory Management
If we only want to get information from the memory, we can use the free
command.
!free
total usado libre compartido búfer/caché disponibleMemoria: 32774516 6563544 20091804 276296 6119168 25479600Swap: 2097148 0 2097148
But since this information is not very easy to digest, we add the flag -h
(human), to make it easier to read.
!free -h
total usado libre compartido búfer/caché disponibleMemoria: 31Gi 6,3Gi 19Gi 270Mi 5,8Gi 24GiSwap: 2,0Gi 0B 2,0Gi
Hard Drive Management
To obtain information from the hard drive, we use the du
command. If we only input this command in the terminal, it will give us the information of all the folders on our machine. Therefore, to avoid obtaining too much information, it is necessary to provide a path that we want to scan.
!du ~/Documentos/web/portafolio/posts/
8 /home/wallabot/Documentos/web/portafolio/posts/__pycache__1648 /home/wallabot/Documentos/web/portafolio/posts/notebooks_translated4288 /home/wallabot/Documentos/web/portafolio/posts/html_files336 /home/wallabot/Documentos/web/portafolio/posts/prueba/tocompress1132 /home/wallabot/Documentos/web/portafolio/posts/prueba16 /home/wallabot/Documentos/web/portafolio/posts/introduccion_python/__pycache__28 /home/wallabot/Documentos/web/portafolio/posts/introduccion_python11232 /home/wallabot/Documentos/web/portafolio/posts/
As before, we add the -h
(human) flag to make it easier to read
!du ~/Documentos/web/portafolio/posts/ -h
8,0K /home/wallabot/Documentos/web/portafolio/posts/__pycache__1,7M /home/wallabot/Documentos/web/portafolio/posts/notebooks_translated4,2M /home/wallabot/Documentos/web/portafolio/posts/html_files336K /home/wallabot/Documentos/web/portafolio/posts/prueba/tocompress1,2M /home/wallabot/Documentos/web/portafolio/posts/prueba16K /home/wallabot/Documentos/web/portafolio/posts/introduccion_python/__pycache__28K /home/wallabot/Documentos/web/portafolio/posts/introduccion_python11M /home/wallabot/Documentos/web/portafolio/posts/
Interface Management
In Ubuntu, by default we start in a graphical interface, but we can open other interfaces, which will not be graphical, by entering CTRL
+ALT
+F<num>
where the number can range from 1 to 6. Only 2 will have the graphical interface and 1 will be the login prompt.
When dealing with multiple interfaces, we may not know which one we are on, so by entering the tty
command, it will tell us which one we are on.
!tty
/dev/pts/0
Package Management
PPA Repositories (Personal Package Archives)
In Linux, package management is done through repositories. This is a list of addresses where the binaries of our programs are located. So, when we want to update or install our programs (we will explain how later), what the operating system will do is check the list of these repositories and go to the indicated addresses to fetch the binaries.
This list of repositories is located in /etc/apt/sources.list
and inside the /etc/apt/sources.list.d
folder. Let's take a look at this list.
terminal("cat /etc/apt/sources.list", max_lines_output=10)
# deb cdrom:[Ubuntu 20.04.2.0 LTS _Focal Fossa_ - Release amd64 (20210209.1)]/ focal main restricted# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to# newer versions of the distribution.deb http://es.archive.ubuntu.com/ubuntu/ focal main restricted# deb-src http://es.archive.ubuntu.com/ubuntu/ focal main restricted## Major bug fix updates produced after the final release of the## distribution.deb http://es.archive.ubuntu.com/ubuntu/ focal-updates main restricted...deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /# deb-src https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /deb https://apt.kitware.com/ubuntu/ focal main# deb-src https://apt.kitware.com/ubuntu/ focal main
The first lines that include the word cd-rom
are references to the installation CD, they always come with the words deb cdrom:
even if it was installed through the network or a USB.
From here on, various lines starting with deb
or deb-src
will appear. Binaries are found in deb
and source code is found in deb-src
.
Every valid repository address has one of these formats:
- deb http://server_address/folder_name version_name (main or universe or multiverse or main restricted, etc)* deb-src http://server_address/folder_name version_name (main or universe or multiverse or main restricted, etc)
The six types of Ubuntu repositories are: 1. Main
The Main
repository is enabled by default and contains only free and open-source software or FOSS
(Free and Open-Source Software).
2. Universo
Like Main
, Universe
also offers FOSS
. The difference is that in this repository it is not Ubuntu that guarantees regular security updates, but rather the community that takes care of its support. It is enabled by default but not always. Some operating systems have it disabled by default and we might need to enable it if we are running a Live Session. If we don't have it added, we can do so with this command:
sudo add-apt-repository universe
What can we find in "Universe"? I would say most of the worthwhile software, such as VLC and OpenShot.
3. Multiverse
From here onwards come the Ubuntu repositories with less freedom. `Multiverse` contains software that is no longer `FOSS` and Ubuntu cannot activate this repository by default due to legal and licensing issues. Additionally, it cannot provide patches and updates. With this in mind, we need to evaluate whether to add it or not, something we can do with this command:
``` bash
```markdown
sudo add-apt-repository multiverse
- Restringido
In the Ubuntu repositories, we can find free and open source software, but this is not possible when it comes to something related to hardware. In the Restricted
repositories, we will find drivers, such as those for graphics cards, touch panels, or network cards.
```markdown
sudo add-apt-repository restricted
- Partner
This repository contains proprietary software compiled by Ubuntu from its partners. 6. Third-party Ubuntu repositories Lastly, we have third-party repositories. Ubuntu always aims to provide the best user experience, and that is one of the reasons why it rejects certain software. There are also developers who prefer to have full control over what they offer, and for that reason, they create their own repositories.
Adding repositories
If we are on Ubuntu, we can add a repository using the command add-apt-repository <repository>
. But as in other distributions that are not Ubuntu, we don't have this command.
Update the repositories
With the apt update
command we will be able to update the latest versions of the packages we have in our repository.
Update packages
Using the apt upgrade
command, we will be able to update the programs we have installed and of which we have previously updated the repository.
Updating the Kernel
If we use the apt dist-upgrade
command, kernel packages will also be updated.
Warning!: Updating kernel packages may cause some packages to break Reminder: When updating kernel packages, it is necessary to restart the computer for the changes to take effect.
Package Search
With the command apt search <package>
we can find packages
terminal("apt search vlc", max_lines_output=10)
Ordenando...Buscar en todo el texto...anacrolix-dms/focal 1.1.0-1 amd64Go UPnP DLNA Digital Media Server with basic video transcodingcubemap/focal 1.4.3-1build1 amd64scalable video reflector, designed to be used with VLCdvblast/focal 3.4-1 amd64Simple and powerful dvb-streaming application...x264/focal 2:0.155.2917+git0a84d98-2 amd64video encoder for the H.264/MPEG-4 AVC standard
List of Installed Packages
To see which packages we have installed, we can use dpkg -l
, this will give us a list of all the packages we have installed on our computer
terminal("dpkg -l", max_lines_output=10)
Deseado=desconocido(U)/Instalar/eliminaR/Purgar/retener(H)| Estado=No/Inst/ficheros-Conf/desempaqUetado/medio-conF/medio-inst(H)/espera-disparo(W)/pendienTe-disparo|/ Err?=(ninguno)/requiere-Reinst (Estado,Err: mayúsc.=malo)||/ Nombre Versión Arquitectura Descripción+++-==========================================-=====================================-============-===========================================================================================================================================================================================================================================================================================================================================================================================================================================ii accountsservice 0.6.55-0ubuntu12~20.04.5 amd64 query and manipulate user account informationii acl 2.2.53-6 amd64 access control list - utilitiesii acpi-support 0.143 amd64 scripts for handling many ACPI eventsii acpid 1:2.0.32-1ubuntu1 amd64 Advanced Configuration and Power Interface event daemonii adduser 3.118ubuntu2 all add and remove users and groups...ii zip 3.0-11build1 amd64 Archiver for .zip filesii zlib1g:amd64 1:1.2.11.dfsg-2ubuntu1.5 amd64 compression library - runtimeii zlib1g:i386 1:1.2.11.dfsg-2ubuntu1.5 i386 compression library - runtimeii zlib1g-dev:amd64 1:1.2.11.dfsg-2ubuntu1.5 amd64 compression library - development
If we want to check if we have a package installed, we can use the previous command and create a pipe
to search for the package name with grep
.
terminal("dpkg -l | grep vlc")
Deseado=desconocido(U)/Instalar/eliminaR/Purgar/retener(H)| Estado=No/Inst/ficheros-Conf/desempaqUetado/medio-conF/medio-inst(H)/espera-disparo(W)/pendienTe-disparo|/ Err?=(ninguno)/requiere-Reinst (Estado,Err: mayúsc.=malo)||/ Nombre Versión Arquitectura Descripción+++-==============-============-============-=================================ii grep 3.4-1 amd64 GNU grep, egrep and fgrepii vlc 3.0.9.2-1 amd64 multimedia player and streamer
Install Packages Downloaded and Not from Repositories
On some occasions, when you want to install a program, they give you a .deb
file, so to install it, we use the command dpkg -i <file.deb>
User Manager
Active User Information with id
Using the id
command I can see which user I am
!id
uid=1000(wallabot) gid=1000(wallabot) grupos=1000(wallabot),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),120(lpadmin),131(lxd),132(sambashare),998(docker)
With this command, I can see my id
, the group id gid
, and the groups I belong to. Users in Debian-based distributions are given an id starting from 1000, while the root user is assigned the id
0.
Active user information with whoami
Another command to know which user I am is whoami
!whoami
wallabot
File with information on all users
The user information is in the /etc/passwd
file
terminal("cat /etc/passwd", max_lines_output=10)
root:x:0:0:root:/root:/bin/bashdaemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologinbin:x:2:2:bin:/bin:/usr/sbin/nologinsys:x:3:3:sys:/dev:/usr/sbin/nologinsync:x:4:65534:sync:/bin:/bin/syncgames:x:5:60:games:/usr/games:/usr/sbin/nologinman:x:6:12:man:/var/cache/man:/usr/sbin/nologinlp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologinmail:x:8:8:mail:/var/mail:/usr/sbin/nologinnews:x:9:9:news:/var/spool/news:/usr/sbin/nologin...sshd:x:126:65534::/run/sshd:/usr/sbin/nologinnvidia-persistenced:x:127:135:NVIDIA Persistence Daemon,,,:/nonexistent:/usr/sbin/nologinfwupd-refresh:x:128:136:fwupd-refresh user,,,:/run/systemd:/usr/sbin/nologinglances:x:129:137::/var/lib/glances:/usr/sbin/nologin
Change a user's password
If you want to change a user's password, you need to use the command passwd <user> <password>
. If the user is not specified, it will use the output of the whoami
command.
Create users with useradd
To create a new user, use the command useradd <user name>
, let's create a new user
!sudo useradd usertest1
Let's see if it is in the file with all the users
!cat /etc/passwd | grep usertest
usertest1:x:1001:1001::/home/usertest1:/bin/sh
As we can see, the user with id
1001 has been created, which is the next one after my user wallabot, which was the last one.
However, when creating this user, it did not ask us to assign a password. Also, if we look at what is inside home
!ls /home
wallabot
Only the wallabot
user's folder exists, but not the test1
user's folder.
Create Users with adduser
Therefore, we are going to see another command to create users that does ask for a password and does create a folder in home
. This command is adduser
!sudo adduser usertest2
[sudo] contraseña para wallabot:Añadiendo el usuario `usertest2' ...Añadiendo el nuevo grupo `usertest2' (1002) ...Añadiendo el nuevo usuario `usertest2' (1002) con grupo `usertest2' ...Creando el directorio personal `/home/usertest2' ...Copiando los ficheros desde `/etc/skel' ...Nueva contraseña:Vuelva a escribir la nueva contraseña:passwd: contraseña actualizada correctamenteCambiando la información de usuario para usertest2Introduzca el nuevo valor, o presione INTRO para el predeterminadoNombre completo []:Número de habitación []:Teléfono del trabajo []:Teléfono de casa []:Otro []:¿Es correcta la información? [S/n] s
If we look in the file with all the users
!cat /etc/passwd | grep usertest
usertest1:x:1001:1001::/home/usertest1:/bin/shusertest2:x:1002:1002:,,,:/home/usertest2:/bin/bash
We see that the user usertest2
has been created.
!ls /home
usertest2 wallabot
And we see that a folder for it has been created in home
To delete a user, you need to use the command userdel <username>
!sudo userdel usertest1
!sudo userdel usertest2
Let's see if they are in the file with all the users.
!cat /etc/passwd | grep usertest
We see that nothing appears anymore, in fact, we see the end of that file.
!cat /etc/passwd | grep usertest!tail /etc/passwd
geoclue:x:122:127::/var/lib/geoclue:/usr/sbin/nologinpulse:x:123:128:PulseAudio daemon,,,:/var/run/pulse:/usr/sbin/nologingnome-initial-setup:x:124:65534::/run/gnome-initial-setup/:/bin/falsegdm:x:125:130:Gnome Display Manager:/var/lib/gdm3:/bin/falsewallabot:x:1000:1000:wallabot,,,:/home/wallabot:/bin/bashsystemd-coredump:x:999:999:systemd Core Dumper:/:/usr/sbin/nologinsshd:x:126:65534::/run/sshd:/usr/sbin/nologinnvidia-persistenced:x:127:135:NVIDIA Persistence Daemon,,,:/nonexistent:/usr/sbin/nologinfwupd-refresh:x:128:136:fwupd-refresh user,,,:/run/systemd:/usr/sbin/nologinglances:x:129:137::/var/lib/glances:/usr/sbin/nologin
Create an Admin User
First, we are going to create a new user, who will not be an administrator at the beginning
!sudo adduser noadmin
Añadiendo el usuario `noadmin' ...Añadiendo el nuevo grupo `noadmin' (1001) ...Añadiendo el nuevo usuario `noadmin' (1001) con grupo `noadmin' ...Creando el directorio personal `/home/noadmin' ...Copiando los ficheros desde `/etc/skel' ...Nueva contraseña:Vuelva a escribir la nueva contraseña:passwd: contraseña actualizada correctamenteCambiando la información de usuario para noadminIntroduzca el nuevo valor, o presione INTRO para el predeterminadoNombre completo []:Número de habitación []:Teléfono del trabajo []:Teléfono de casa []:Otro []:¿Es correcta la información? [S/n] s
Let's see which groups the user we just created belongs to, for this we use the command groups <user>
!groups noadmin
noadmin : noadmin
As we can see, it is only in the noadmin
group, which is a group that was created when the user was created.
Let's see which groups my user belongs to
!groups wallabot
wallabot : wallabot adm cdrom sudo dip plugdev lpadmin lxd sambashare docker
As we can see, my user belongs to several more groups, including one called sudo
. Users who have access to this group have administrative powers, so to give the new user we have created these powers, we need to add them to the sudo
group.
To add a user to a group, there are two ways: one is with the command gpasswd -a <user> <group>
!sudo gpasswd -a noadmin sudo
Añadiendo al usuario noadmin al grupo sudo
Let's now see which groups the user noadmin
belongs to
!groups noadmin
noadmin : noadmin sudo
As we can see, they already belong to the sudo group, so they already have administrator privileges.
We remove the user noadmin
from the sudo
group with the command gpasswd -d <user> <group>
!sudo gpasswd -d noadmin sudo
Eliminando al usuario noadmin del grupo sudo
We see that noadmin
no longer belongs to the sudo
group
!groups noadmin
noadmin : noadmin
The second command to add a user to a group is usermod -aG <group> <user>
!sudo usermod -aG sudo noadmin
We return to see which groups the user noadmin
belongs to
!groups noadmin
noadmin : noadmin sudo
We remove the user noadmin
from the sudo
group and delete it.
!sudo gpasswd -d noadmin sudo
Eliminando al usuario noadmin del grupo sudo
!sudo userdel noadmin
Command History
history
If we enter the history
command in the terminal, we see a history of the commands used.
!history
1009 docker build . nvidia/cuda1010 docker build --help1011 docker build --build-arg nvidia/cuda1012 docker build --build-arg [nvidia/cuda]1013 cd ../docker/1014 docker ps -a1015 docker rm boring_wescoff1016 docker compose up -d1017 docker compose exec deepstream61 bash1018 cd ......1996 ps1997 ps aux1998 camerasIP.sh1999 sudo su2000 sudo useradd usertest2001 sudo userdel usertest2002 sudo useradd usertest2003 sudo userdel usertest2004 sudo su2005 sudo apt install history2006 history2007 clear2008 history
If we want to execute one of the commands from the history, we do it using !<num command>
, for example, if I want to execute command 1996 again
! !1996
PID TTY TIME CMD6610 pts/0 00:00:00 bash20826 pts/0 00:00:00 ps
reverse-i-search
A more refined way to search the history is to enter CTRL
+r
. By doing this, the following message will appear in the console
!reverse-i-search)`':
So as you type, commands that match what you've entered will appear. For example, if I type if
, the last time I used ifconfig
will appear.
If we press CTRL
+r
again, older matches will start to appear
Delete Commands from History
There are commands like ls
, cd
, pwd
that don't contribute much by being in the history, so it can be configured not to save them in the history. To do this, we modify the ~/.bashrc
file and add the line HISTIGNORE="pwd:ls:cd"
Security
Firewall ufw
Ubuntu comes with the ufw
firewall installed, but to check it we use the following command
!sudo ufw status
Estado: inactivo
As we can see by default it is inactive, so we are going to create a set of rules. For example, let's start by opening port 22 (SSH), for this we use the command sudo allow <port> comment "<comment>"
, with which we open a port and add a comment.
!sudo ufw allow 22 comment 'ssh'
Regla añadidaRegla añadida (v6)
As we can see, it has opened port 22 for IPv4 and IPv6. Now let's activate ufw
with the command ufw enable
!sudo ufw enable
El cortafuegos está activo y habilitado en el arranque del sistema
If we want to see the rules we have in the firewall we use the ufw status
command.
!sudo ufw enable
Hasta Acción Desde----- ------ -----22 ALLOW Anywhere # ssh22 (v6) ALLOW Anywhere (v6) # ssh
We can also tell it to show us the numbered rules with the command ufw status numbered
!sudo ufw status numbered
Estado: activoHasta Acción Desde----- ------ -----[ 1] 22 ALLOW IN Anywhere # ssh[ 2] 22 (v6) ALLOW IN Anywhere (v6) # ssh
As we have them numbered, we can remove one using the command ufw delete <rule number>
, so to delete the rule for IPv6 we do
!sudo ufw delete 2
Estado: activoBorrando:allow 22 comment 'ssh'¿Continuar con la operación (s|n)? sRegla eliminada (v6)
We see the state again
!sudo ufw status numbered
Estado: activoHasta Acción Desde----- ------ -----[ 1] 22 ALLOW IN Anywhere # ssh
We see that rule number 2 has indeed been removed.
If we want to enable SSH connection from a single IP, we use the flag from <IP>
!sudo ufw allow from 192.168.1.103 proto tcp to any port 22 comment 'ssh ip'
Regla añadida
We check the rules again
!sudo ufw status numbered
Estado: activoHasta Acción Desde----- ------ -----[ 1] 22 ALLOW IN Anywhere # ssh[ 2] 22/tcp ALLOW IN 192.168.1.103 # ssh ip
If we want to delete all the rules, we use the reset
command
!sudo ufw reset
Estado: activoReiniciando todas las reglas a sus valores predeterminados instalados.¿Continuar con la operación (s|n)? sRespaldando «user.rules» en «/etc/ufw/user.rules.20221205_171730»Respaldando «before.rules» en «/etc/ufw/before.rules.20221205_171730»Respaldando «after.rules» en «/etc/ufw/after.rules.20221205_171730»Respaldando «user6.rules» en «/etc/ufw/user6.rules.20221205_171730»Respaldando «before6.rules» en «/etc/ufw/before6.rules.20221205_171730»Respaldando «after6.rules» en «/etc/ufw/after6.rules.20221205_171730»
We check the status again
!sudo ufw status numbered
Estado: inactivo
We see that there are no more rules
To disable the firewall, use the command ufw disable
!sudo ufw disable
El cortafuegos está detenido y deshabilitado en el arranque del sistema
We check the status again
!sudo ufw status
Estado: inactivo
Security audit with Lynis
To install Lynis, you have to use the command sudo apt install lynis
To audit your system, you need to use the command lynis audit system
. This will start scanning the entire system and report it to you.
I will not show the result of my system scan to avoid displaying my vulnerabilities on the internet
Command Programming
Scheduling Periodic Commands with cron
With the cron
command we can schedule commands to run periodically. To do this, we have to edit the file /etc/crontab
!cat /etc/crontab
# /etc/crontab: system-wide crontab# Unlike any other crontab you don't have to run the `crontab'# command to install the new version when you edit this file# and files in /etc/cron.d. These files also have username fields,# that none of the other crontabs do.SHELL=/bin/shPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin# Example of job definition:# .---------------- minute (0 - 59)# | .------------- hour (0 - 23)# | | .---------- day of month (1 - 31)# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat# | | | | |# * * * * * user-name command to be executed17 * * * * root cd / && run-parts --report /etc/cron.hourly25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )#
As you can see, in this file, there are a series of commands that are executed periodically. The format of these commands is as follows
<minute> <hour> <day of the month> <month> <day of the week> <user> <command>
To correctly create the date on which you want the command to be executed, there are a lot of online pages that help you write it correctly, such as crontab guru
Scheduling One-Time Commands with at
When we want a command to be executed in the future, but we don't want it to be executed periodically, instead only once, we can use the at
command. For example, you turn on an Azure or Amazon machine, which charges you, and you want to be sure it will turn off and not surprise you on the bill, you can schedule it to turn off at night. That way, even if you forget to turn it off, it will turn off automatically.
We run an ls
in the /tmp
folder
!ls -l /tmp
total 60-rw------- 1 wallabot wallabot 0 sep 24 08:51 config-err-QM3AAe-rw-r--r-- 1 root root 2049 sep 24 08:51 glances-root.logdrwx------ 2 wallabot wallabot 4096 sep 24 09:06 pyright-9853-BG3nXEXw0Taodrwxrwxr-x 3 wallabot wallabot 4096 sep 24 09:06 python-languageserver-cancellationdrwx------ 3 root root 4096 sep 24 08:51 snap-private-tmpdrwx------ 2 wallabot wallabot 4096 sep 24 08:51 ssh-mHjlSPPoqCp7drwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-colord.service-rpjPridrwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-fwupd.service-FzPoQfdrwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-geoclue.service-F6pMWidrwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-ModemManager.service-Orf6Bidrwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-switcheroo-control.service-1QXRqjdrwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-systemd-logind.service-lL35tgdrwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-systemd-resolved.service-iaswSidrwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-systemd-timesyncd.service-Yet8ljdrwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-upower.service-oTL7Ggdrwx------ 2 wallabot wallabot 4096 sep 24 09:31 tracker-extract-files.1000
Now let's program the creation of a new file in /tmp
in 5 minutes
!at 09:55 touch /tmp/at.txt
warning: commands will be executed using /bin/shat> touch /tmp/at.txtat> <EOT>job 1 at Sun Sep 24 09:55:00 2023
As we can see, it is necessary to write at <time>
and on the next line the command we want to run.
Let's now see the files in /tmp
!ls -l /tmp
total 60-rw-rw-r-- 1 wallabot wallabot 0 sep 24 09:55 at.txt-rw------- 1 wallabot wallabot 0 sep 24 08:51 config-err-QM3AAe-rw-r--r-- 1 root root 2049 sep 24 08:51 glances-root.logdrwx------ 2 wallabot wallabot 4096 sep 24 09:06 pyright-9853-BG3nXEXw0Taodrwxrwxr-x 3 wallabot wallabot 4096 sep 24 09:06 python-languageserver-cancellationdrwx------ 3 root root 4096 sep 24 08:51 snap-private-tmpdrwx------ 2 wallabot wallabot 4096 sep 24 08:51 ssh-mHjlSPPoqCp7drwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-colord.service-rpjPridrwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-fwupd.service-FzPoQfdrwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-geoclue.service-F6pMWidrwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-ModemManager.service-Orf6Bidrwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-switcheroo-control.service-1QXRqjdrwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-systemd-logind.service-lL35tgdrwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-systemd-resolved.service-iaswSidrwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-systemd-timesyncd.service-Yet8ljdrwx------ 3 root root 4096 sep 24 08:51 systemd-private-371a1d9479324db8bd79b6844b8b589b-upower.service-oTL7Ggdrwx------ 2 wallabot wallabot 4096 sep 24 09:31 tracker-extract-files.1000
As we can see, there is an at.txt
that has been created at 09:55
Keyboard Shortcuts
Below are some useful keyboard shortcuts for using the terminal* Ctrl+a: moves the cursor to the beginning of the command line. * Ctrl+e: moves the cursor to the end of the command line. * Ctrl+l: clears the terminal, similar to what the clear
command does.* Ctrl+u: clears from the cursor position to the beginning of the line. If at the end, it clears the entire line.* Ctrl+k: clears from the cursor position to the end of the line. If at the beginning, it clears the entire line.* Ctrl+h: does the same as the backspace key, deleting the character immediately before the cursor's position.* Ctrl+w: deletes the word immediately before the cursor.* Alt+d or Esc+d: deletes the next word after the cursor.* Ctrl+p: sets the command line with the last entered command.* Ctrl+r: starts the search for previously used commands by typing part of a previously executed command including the options and parameters. Once a search is done, pressing the key combination again will find previous matches.* Ctrl+c: terminates the currently running process, useful for regaining control of the system.* Ctrl+d: exits the terminal, similar to the exit command.* Ctrl+z: suspends the execution of the running process and puts it in the background; with the fg command, we can resume its execution. * Ctrl+t: swaps the positions of the two characters before the cursor, useful for correcting typos.* Esc+t: swaps the position of the two words before the cursor, useful for correcting typos.* Alt+f: move the cursor to the beginning of the next word on the line, same as Ctrl+right in the GNOME terminal. * Alt+b: moves the cursor to the beginning of the previous word on the line, the same as Ctrl+left in the GNOME terminal.* Tab: autocompletes commands or directory/file paths. * Ctrl+Shift+f: opens a dialog to search for text in the terminal output.* Ctrl+Shift+g: search for the next occurrence of the previous search in the terminal. * Ctrl+Shift+h: search for the previous occurrence of the previous search in the terminal.* Ctrl+Shift+c: copies the selected text from the terminal to the clipboard.* Ctrl+Shift+v: pastes the clipboard text into the command line.* Up: sets the previous command from the history in the command line, same as Ctrl+p.* Down: sets the next command from the history in the command line.* Left Mouse: selects lines of terminal text.* Ctrl+Left Mouse: selects blocks of text from the terminal.
Folder System in Linux
In the following image, we can see what the folder system looks like in Linux This image has been taken from the post on LinkedIn by Roberto Morais
content_filter_results: {'hate': {'filtered': False, 'severity': 'safe'}, 'self_harm': {'filtered': False, 'severity': 'safe'}, 'sexual': {'filtered': True, 'severity': 'medium'}, 'violence': {'filtered': False, 'severity': 'safe'}} message_content: None
You forgot to use sudo
Have you ever gone to use a command that you needed to run with sudo
, but forgot to type sudo
? Well, after receiving the corresponding error, if you do sudo !!
the previous command will be executed with sudo
.
!apt update
Leyendo lista de paquetes... HechoE: No se pudo abrir el fichero de bloqueo «/var/lib/apt/lists/lock» - open (13: Permiso denegado)E: No se pudo bloquear el directorio /var/lib/apt/lists/W: Se produjo un problema al desligar el fichero /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permiso denegado)W: Se produjo un problema al desligar el fichero /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permiso denegado)
As you can see, when running sudo update
it gives us an error, but if we now execute sudo !!
it will run sudo apt update
.
!sudo !!
[sudo] contraseña para wallabot:
Kernel Messages
With the dmesg
(display kernel ring buffer messages) command we can see kernel messages. For example, this is very useful to see if a USB device has been connected, or to debug HW errors on our computer.
!dmesg | tail
[ 35.812312] input: LogiOps Virtual Input as /devices/virtual/input/input33[ 35.916406] input: LogiOps Virtual Input as /devices/virtual/input/input34[ 36.002064] input: LogiOps Virtual Input as /devices/virtual/input/input35[ 63.879806] input: MX Master 3 as /devices/virtual/misc/uhid/0005:046D:B023.0006/input/input36[ 63.879931] logitech-hidpp-device 0005:046D:B023.0006: input,hidraw3: BLUETOOTH HID v0.15 Keyboard [MX Master 3] on 4c:77:cb:1d:66:d0[ 63.902120] logitech-hidpp-device 0005:046D:B023.0006: HID++ 4.5 device connected.[ 69.604899] input: MX Keys Keyboard as /devices/virtual/misc/uhid/0005:046D:B35B.0007/input/input37[ 69.605221] input: MX Keys Mouse as /devices/virtual/misc/uhid/0005:046D:B35B.0007/input/input38[ 69.606204] hid-generic 0005:046D:B35B.0007: input,hidraw4: BLUETOOTH HID v0.13 Keyboard [MX Keys] on 4c:77:cb:1d:66:d0[ 188.285030] input: T9 (AVRCP) as /devices/virtual/input/input40
With the --follow
flag we can see in real-time the new messages that are generated
!dmesg --follow
Hardware Information
With lshw
we can see hardware information of our computer
!dmesg --follow!lshw
[ 0.000000] Linux version 5.15.0-84-generic (buildd@lcy02-amd64-005) (gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #93~20.04.1-Ubuntu SMP Wed Sep 6 16:15:40 UTC 2023 (Ubuntu 5.15.0-84.93~20.04.1-generic 5.15.116)[ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-5.15.0-84-generic root=UUID=59002381-d88d-44a6-b83d-8c5a226ce058 ro quiet splash vt.handoff=7[ 0.000000] KERNEL supported cpus:[ 0.000000] Intel GenuineIntel[ 0.000000] AMD AuthenticAMD[ 0.000000] Hygon HygonGenuine[ 0.000000] Centaur CentaurHauls[ 0.000000] zhaoxin Shanghai[ 0.000000] BIOS-provided physical RAM map:[ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009ffff] usable[ 0.000000] BIOS-e820: [mem 0x00000000000a0000-0x00000000000fffff] reserved[ 0.000000] BIOS-e820: [mem 0x0000000000100000-0x0000000009d01fff] usable[ 0.000000] BIOS-e820: [mem 0x0000000009d02000-0x0000000009ffffff] reserved[ 0.000000] BIOS-e820: [mem 0x000000000a000000-0x000000000a1fffff] usable[ 0.000000] BIOS-e820: [mem 0x000000000a200000-0x000000000a20bfff] ACPI NVS[ 0.000000] BIOS-e820: [mem 0x000000000a20c000-0x00000000b8983fff] usable[ 0.000000] BIOS-e820: [mem 0x00000000b8984000-0x00000000b8acdfff] reserved[ 0.000000] BIOS-e820: [mem 0x00000000b8ace000-0x00000000b8c56fff] ACPI data[ 0.000000] BIOS-e820: [mem 0x00000000b8c57000-0x00000000b9107fff] ACPI NVS[ 0.000000] BIOS-e820: [mem 0x00000000b9108000-0x00000000ba55cfff] reserved[ 0.000000] BIOS-e820: [mem 0x00000000ba55d000-0x00000000bcffffff] usable[ 0.000000] BIOS-e820: [mem 0x00000000bd000000-0x00000000bfffffff] reserved[ 0.000000] BIOS-e820: [mem 0x00000000f8000000-0x00000000fbffffff] reserved...[ 35.916406] input: LogiOps Virtual Input as /devices/virtual/input/input34[ 36.002064] input: LogiOps Virtual Input as /devices/virtual/input/input35[ 63.879806] input: MX Master 3 as /devices/virtual/misc/uhid/0005:046D:B023.0006/input/input36[ 63.879931] logitech-hidpp-device 0005:046D:B023.0006: input,hidraw3: BLUETOOTH HID v0.15 Keyboard [MX Master 3] on 4c:77:cb:1d:66:d0[ 63.902120] logitech-hidpp-device 0005:046D:B023.0006: HID++ 4.5 device connected.[ 69.604899] input: MX Keys Keyboard as /devices/virtual/misc/uhid/0005:046D:B35B.0007/input/input37[ 69.605221] input: MX Keys Mouse as /devices/virtual/misc/uhid/0005:046D:B35B.0007/input/input38[ 69.606204] hid-generic 0005:046D:B35B.0007: input,hidraw4: BLUETOOTH HID v0.13 Keyboard [MX Keys] on 4c:77:cb:1d:66:d0[ 188.285030] input: T9 (AVRCP) as /devices/virtual/input/input40AVISO: debería ejecutar este programa como superusuario.wallabotdescripción: Computeranchura: 64 bitscapacidades: smp vsyscall32*-coredescripción: Motherboardid físico: 0*-memorydescripción: Memoria de sistemaid físico: 0tamaño: 32GiB...producto: PnP device PNP0501id físico: 6capacidades: pnpconfiguración: driver=serial*-pnp00:05producto: PnP device PNP0c02id físico: 7capacidades: pnpconfiguración: driver=systemAVISO: la salida puede ser incompleta o imprecisa, debería ejecutar este programa como superusuario.
Cowsay
There is a command called cowsay
to which you pass a text as a parameter and it draws a cow saying that text.
It is possible that you don't have it installed, so to install it, you need to enter the command
```sudo apt install cowsay```
terminal("cowsay MaximoFN")
__________< MaximoFN >----------^__^(oo)_______(__) )/\||----w ||| ||
If you add the -f dragon
flag, it is said by a dragon.
terminal("cowsay -f dragon MaximoFN")
__________< MaximoFN >----------/ //\|___/| / // \/0 0 __ / // |/ / /_/ // |@_^_@'/ /_ // |//_^_/ /_ // | \( //) | /// | \( / /) _|_ / ) // | _\( // /) '/,_ _ _/ ( ; -. | _ _.-~ .-~~~^-.(( / / )) ,-{ _ `-.|.-~-. .~ `.(( // / )) '/ / ~-. _ .-~ .-~^-. \(( /// )) `. { } / \(( / )) .----~-. -' .~ `. ^-.///.----..> _ -~ `. ^-` ^-_///-._ _ _ _ _ _ _}^ - - - - ~ ~-- ,.-~/.-~
terminal("cowsay -f dragon-and-cow MaximoFN")
__________< MaximoFN >----------^ /^/ // \|___/| / // .\/O O __ / // | *----*/ / /_/ // | |@___@` /_ // | / \0/0/| /_ // | \0/0/0/0/| /// | | |0/0/0/0/0/_|_ / ( // | _ | /0/0/0/0/0/0/`/,_ _ _/ ) ; -. | _ _.-~ / /,-} _ *-.|.-~-. .~ ~__/ `/ / ~-. _ .-~ /____(oo) *. } { /( (--) .----~-. -` .~//__\ __ Ack! ///.----..< _ -~// \ ///-._ _ _ _ _ _ _{^ - - - - ~
Cleaning
Since the folder prueba
has been created, we delete it to leave everything as we found it.
!rm -r prueba