20 comandos de Linux para el administrador del sistema
Linux ofrece innumerables comandos y utilidades que lo ayudan a realizar las tareas de administración de su sistema de manera rápida y eficiente.
Tu trabajo como administrador del sistema incluye instalar y ejecutar software, controlar el acceso, monitorear, garantizar la disponibilidad, copias de seguridad, restaurar copias de seguridad y, por supuesto, combatir incendios. 😜
En este artículo, review some of the commands frequently used by Linux system administrators in their day to day work.
uname
Uso uname
comando con el -a
flag to print system information. This command will show you the kernel name, kernel release, kernel version, hostname, processor type & your hardware platform information.
ubuntu@ubuntu18:~$ uname -a
Linux ubuntu18 5.3.0-1028-azure #29~18.04.1-Ubuntu SMP Fri Jun 5 14:32:34 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Esto es lo que esto significa:
kernel name:Linux
hostname: ubuntu18
kernel release: 5.3.0-1028-azure
kernel version: #29~18.04.1-Ubuntu SMP Fri Jun 5 14:32:34 UTC 2020
machine hardware name: x86_64
processor: x86_64
hardware-platform: x86_64
operating system: GNU/Linux
df
Uso df
command to verify the size of the filesystem and the space available. This command used by itself shows output in 1K
Bloques
ubuntu@ubuntu18:~$ df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 437208 0 437208 0% /dev
tmpfs 91100 692 90408 1% /run
/dev/sda1 30309264 2383952 27908928 8% /
....
Optión -h
muestra la salida en un formato legible por humanos, es decir, en MB
y GB
.
ubuntu@ubuntu18:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 427M 0 427M 0% /dev
tmpfs 89M 692K 89M 1% /run
/dev/sda1 29G 2.3G 27G 8% /
tmpfs 445M 0 445M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 445M 0 445M 0% /sys/fs/cgroup
/dev/sda15 105M 3.6M 101M 4% /boot/efi
/dev/sdb1 3.9G 16M 3.7G 1% /mnt
tmpfs 89M 0 89M 0% /run/user/1001
Para ignorar cualquier sistema de archivos, por ejemplo, tmpfs, que es para una salida más limpia, use flag -x
ubuntu@ubuntu18:~$ df -h -x tmpfs
Filesystem Size Used Avail Use% Mounted on
udev 427M 0 427M 0% /dev
/dev/sda1 29G 2.3G 27G 8% /
/dev/sda15 105M 3.6M 101M 4% /boot/efi
/dev/sdb1 3.9G 16M 3.7G 1% /mnt
Para enumerar solo un tipo de sistema de archivos específico, use -t
bandera. por ejemplo, para ver solo el sistema de archivos ext4:
ubuntu@ubuntu18:~$ df -h -t ext4
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 29G 2.3G 27G 8% /
/dev/sdb1 3.9G 16M 3.7G 1% /mnt
El uso de la bandera de total agregará una línea que muestra los totales generales:
ubuntu@ubuntu18:~$ df -h -t ext4 --total
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 29G 2.3G 27G 8% /
/dev/sdb1 3.9G 16M 3.7G 1% /mnt
<b>total 33G 2.3G 31G 8% -</b>
du
Para verificar el uso de espacio en disco en un directorio, use du
mando. Por ejemplo, para ver el uso del espacio en disco en el directorio / var / log. Utilizar -h
bandera para formato legible por humanos.
ubuntu@ubuntu18:~$ sudo du -h /var/log
24K /var/log/Microsoft/Azure/NetworkWatcherAgent/Logs
28K /var/log/Microsoft/Azure/NetworkWatcherAgent
32K /var/log/Microsoft/Azure
36K /var/log/Microsoft
60K /var/log/apt
4.0K /var/log/samba
177M /var/log/journal/0f4f926f583b4691af7de11025b19ff6
177M /var/log/journal
...
204M /var/log
Para ver solo el uso total solo use -s
(resumen) bandera.
ubuntu@ubuntu18:~$ sudo du -hs /var/log
204M /var/log
gratuita,
Use el comando libre para ver la memoria del sistema total, usada y libre. Utilizar -h
bandera para formato legible por humanos.
ubuntu@ubuntu18:~$ free -h
total used free shared buff/cache available
Mem: 889M 272M 100M 712K 517M 443M
Swap: 0B 0B 0B
total - Total installed memory (memtotal + swaptotal)
used - used memory
free - unused memory (memfree + swapfree)
buffers - memory used by kernel buffers
cache - memory used by page caches
buff/cache - sum of buffers and cache
available - Estimated memory available for starting new applications, without swapping
ps
Uso ps
to display status information about processes running on the system. To see all processes owned by user ubuntu, use -u
bandera con el nombre de usuario:
ubuntu@ubuntu18:~$ ps -u ubuntu
PID TTY TIME CMD
7804 ? 00:00:00 systemd
7805 ? 00:00:00 (sd-pam)
7940 ? 00:00:00 sshd
7941 pts/0 00:00:00 bash
8111 ? 00:00:00 sshd
8112 pts/1 00:00:00 bash
13868 ? 00:00:00 sshd
13869 pts/2 00:00:00 bash
13885 pts/0 00:00:00 man
13895 pts/0 00:00:00 pager
18111 pts/2 00:00:00 man
18121 pts/2 00:00:00 pager
18485 pts/1 00:00:00 ps
Para ver todo processes run ps with aux flags:
ubuntu@ubuntu18:~$ ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.7 160076 7020 ? Ss Jun29 0:34 /sbin/init
root 2 0.0 0.0 0 0 ? S Jun29 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? I< Jun29 0:00 [rcu_gp]
root 4 0.0 0.0 0 0 ? I< Jun29 0:00 [rcu_par_gp]
root 6 0.0 0.0 0 0 ? I< Jun29 0:00 [kworker/0:0H-kb]
....
donde
Título | Sentido |
PID | Process Número de identificación |
%UPC | Percentage of CPU time the process esta usando |
% MEM | Percentage of RAM process esta usando |
VSZ | Se utiliza memoria virtual en KB |
RSS | Physical memory the process is using in KB |
TTY | Terminal associated con el process |
STAT | R – Running or ready to run, S – Sleeping, I – Idle, T – Stopped, Z – Zombie, D – Waiting for Disk I/O, X – Dead, W – Swapped out, N – Low priority process, < – High priority process |
parte superior
Aunque la ps
command shows a snapshot of the state of processes at any moment, top shows a continuously updating (every three seconds, by default) list of system processes in order of process actividad.
El top
command output consists of two main parts: The system summary at the top and the table of processes sorted by CPU activity.
top - 14:25:32 up 44 days, 11:37, 1 user, load average: 0.00, 0.00, 0.00
Tasks: 114 total, 1 running, 59 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.3 us, 0.0 sy, 0.0 ni, 99.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 910992 total, 101208 free, 274712 used, 535072 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 458492 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
50497 ubuntu 20 0 44528 3944 3368 R 0.7 0.4 0:00.15 top
1 root 20 0 160076 7020 4400 S 0.0 0.8 0:34.85 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.08 kthreadd
3 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 rcu_gp
4 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 rcu_par_gp
6 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker/0:+
9 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 mm_percpu_+
Algunos de los campos del resumen del sistema son los siguientes:
up | Tiempo de actividad. Tiempo desde que se inició la máquina por última vez. | ||||||||||||||||
promedio de carga | Load average refers to the number of processes that are waiting to run, value less than 1.0 means the machine is not busy. There are 3 values. First is the average of the last 60 seconds, second is the average of the last 5 minutes and the third shows the average of the last 15 minutes. | ||||||||||||||||
% CPU (s)
| Esta fila describe las actividades de la CPU.
|
Process table fields are as follows:
PID | Process Número de identificación |
USUARIO | Process propietario |
PR | Prioridad |
NI | Nice propuesta de |
VIRTUAL | Virtual memory used by the process (KB) |
RES | Physical memory used by the process |
SHR | Shared memory used by the process |
S | Process status. R – Running, S – sleeping, I – Idle, T – stopped, Z – zombie, D – waiting for disk I/O, W- swapped out, X – dead |
%UPC | Tiempo de CPU process is using in percentage |
% MEM | The physical memory process esta usando |
HORA [+] | Total CPU time used by the process |
COMANDO | Nombre del programa |
Aunque la top
se está ejecutando, puede emitir una serie de comandos. prensa h
or ?
para ver los comandos que se pueden ejecutar mientras se ejecuta top. prensa k
matar a un process. prensa q
para salir de la parte superior.
cavar
dig
es una gran herramienta para consultas de DNS. Se utiliza de la siguiente manera:
dig <DNS server> <domain> <query-type>
donde
- es el nombre del servidor DNS que desea consultar
- es el nombre de dominio sobre el que desea consultar
- es el nombre del registro que desea conocer: A, MX, NS SOA, etc.
Para suprimir la salida detallada, use + bandera corta.
Para ver el registro A para el uso de google.com:
ubuntu@ubuntu18:~$ dig google.com +short
172.217.164.174
Para ver los registros MX de google.com, utilice:
ubuntu@ubuntu18:~$ dig google.com MX +short
50 alt4.aspmx.l.google.com.
10 aspmx.l.google.com.
20 alt1.aspmx.l.google.com.
40 alt3.aspmx.l.google.com.
30 alt2.aspmx.l.google.com.
Si necesita consultar registros DNS en Internet, puede utilizar el Herramienta de búsqueda de DNS.
quien y w
who
muestra los usuarios que han iniciado sesión.
ubuntu@ubuntu18:~$ who
ubuntu pts/0 2020-08-14 17:28 (183.83.211.129)
ubuntu pts/1 2020-08-14 17:58 (183.83.211.129)
w
shows users currently logged on and their processes. The header shows the current time, system uptime, number of users logged on, and system load averages.
ubuntu@ubuntu18:~$ w
18:07:33 up 46 days, 15:19, 2 users, load average: 0.00, 0.00, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
ubuntu pts/0 183.83.211.129 17:28 2.00s 0.10s 0.00s w
ubuntu pts/1 183.83.211.129 17:58 9:07 0.05s 0.01s vi
The next part shows the usernames, the terminal, and the remote IP from which they are logged on, login time, idle time, JCPU, PCPU, and the program they are running. JCPU is the time used by all processes attached to the tty whereas PCPU is the time used by the current process.
alquitrán
With GNU tar you can archive multiple files into a single file.
As an example create a directory myfiles and three files a.txt, b.txt, c.txt in myfiles directory:
ubuntu@ubuntu18:~$ mkdir myfiles ; touch myfiles/{a.txt,b.txt,c.txt}
Now to create un arcohive named allfiles.tar containing all files in myfiles directory:
ubuntu@ubuntu18:~$ tar -cvf allfiles.tar myfiles
myfiles/
myfiles/c.txt
myfiles/a.txt
myfiles/b.txt
List all files in the current directory. You can see myfiles directory and allfiles.tar archive:
ubuntu@ubuntu18:~$ ls
allfiles.tar myfiles
You may unpack an archive with -x flag. So, to unpack allfiles.tar:
ubuntu@ubuntu18:~$ tar -xvf allfiles.tar
myfiles/
myfiles/c.txt
myfiles/a.txt
myfiles/b.txt
You may also compress this archive with -z flag. This would create un arcohive compressed with gzip.
ubuntu@ubuntu18:~$ tar -zcvf allfiles.tar.gz myfiles
myfiles/
myfiles/c.txt
myfiles/a.txt
myfiles/b.txt
ubuntu@ubuntu18:~$ ls
allfiles.tar.gz myfiles
To unpack a compressed archive utilizan el -z
-x
bandera.
ubuntu@ubuntu18:~$ tar -zxvf allfiles.tar.gz
myfiles/
myfiles/c.txt
myfiles/a.txt
myfiles/b.txt
grep
grep
se utiliza para buscar un patrón en un archivo o un conjunto de archivos. Imprime todas las líneas que coinciden con ese patrón. Por ejemplo, para buscar la línea que contiene "ServerRoot" en /etc/apache2/apache2.conf:
ubuntu@ubuntu18:~$ grep ServerRoot /etc/apache2/apache2.conf
# ServerRoot: The top of the directory tree under which the server's
#ServerRoot "/etc/apache2"
Para buscar en todos los archivos de un directorio, utilice *
. Para incluir la búsqueda en subdirectorios, utilice -r
(recursivo) bandera. Entonces, para buscar todas las líneas que contienen el patrón "VirtualHost" en todos los archivos en / etc / apache2:
ubuntu@ubuntu18:~$ cd /etc/apache2
ubuntu@ubuntu18:/etc/apache2$ grep -r VirtualHost *
apache2.conf:# If you do not specify an ErrorLog directive within a <VirtualHost>
apache2.conf:# logged here. If you *do* define an error logfile for a <VirtualHost>
conf-available/localized-error-pages.conf:# even on a per-VirtualHost basis. If you include the Alias in the global server
conf-available/other-vhosts-access-log.conf:# Define an access log for VirtualHosts that don't define their own logfile
ports.conf:# have to change the VirtualHost statement in
sites-available/000-default.conf:<VirtualHost *:80>
...
rsync
<a href="https://geekflare.com/rsync-guide/">rsync</a> is a fast command-line tool for synchronizing files and directories between two locations. Can be used for both local and remote copying and is fast because it sends only the differences between the source files and the existing files in the destination.
Se usa ampliamente para copias de seguridad y como un comando de copia mejorado para el uso diario.
Aquí hay un ejemplo:
To copy/rsync all files from myfiles directory to backups directory:
ubuntu@ubuntu18:~$ rsync -avh myfiles/ /backups
sending incremental file list
./
a.txt
b.txt
c.txt
sent 218 bytes received 76 bytes 588.00 bytes/sec
total size is 0 speedup is 0.00
Para rsync all files from myfiles directory to backups directory on a remote host, include remote_user @remote_host
in destination name. So, to rsync myfiles folder to a remote host with IP 10.0.0.50:
vagrant@ubuntu-xenial:~$ rsync -avh myfiles/ vagrant@10.0.0.50:/home/vagrant
vagrant@10.0.0.50's password:
sending incremental file list
./
a.txt
b.txt
c.txt
sent 230 bytes received 76 bytes 47.08 bytes/sec
total size is 0 speedup is 0.00
ss
ss
El comando se usa para volcar estadísticas de sockets, similar a la utilidad netstat heredada. Para mostrar los sockets TCP, utilice -t
bandera.
ubuntu@ubuntu18:~$ ss -t
State Recv-Q Send-Q Local Address:Port Peer Address:Port
ESTAB 0 0 10.0.0.4:53852 168.63.129.16:8037
ESTAB 0 0 10.0.0.4:ssh 183.83.211.129:64118
ESTAB 0 0 10.0.0.4:33256 169.254.169.254:http
ESTAB 0 1080 10.0.0.4:ssh 222.186.30.35:11527
ESTAB 0 0 10.0.0.4:ssh 183.83.211.129:63049
Esto no mostraría los sockets que están escuchando. Para incluir enchufes de escucha y no escucha, use -t
y -a
banderas.
ubuntu@ubuntu18:~$ ss -t -a
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:ssh 0.0.0.0:*
LISTEN 0 80 127.0.0.1:mysql 0.0.0.0:*
LISTEN 0 128 127.0.0.53%lo:domain 0.0.0.0:*
ESTAB 0 0 10.0.0.4:53852 168.63.129.16:8037
ESTAB 0 0 10.0.0.4:ssh 183.83.211.129:64118
ESTAB 0 0 10.0.0.4:33256 169.254.169.254:http
ESTAB 0 1080 10.0.0.4:ssh 222.186.30.35:11527
ESTAB 0 120 10.0.0.4:ssh 183.83.211.129:63049
LISTEN 0 128 [::]:ssh [::]:*
LISTEN 0 128 *:http *:*
locate
El locate
command uses a database to search for files and actually can be much faster than find command. Very simple to use, to search for a file, say, apache2.conf:
ubuntu@ubuntu18:~$ locate apache2.conf
/etc/apache2/apache2.conf
/var/lib/dpkg/info/apache2.conffiles
Puedes usar -c
marque si solo desea el recuento de archivos que coinciden con el patrón de búsqueda.
ubuntu@ubuntu18:~$ locate -c apache2.conf
2
At times, you may need to refresh the database used by locate, which is mlocate. To update the database use updatedb
mando. Esto necesitaría privilegios de superusuario.
ubuntu@ubuntu18:~$ sudo updatedb
encontrar
Uno de los más utilizados comandos en Linux. Úselo para buscar archivos según nombres de archivo, permisos, ID de usuario, ID de grupo, tamaño, tipo de archivo, además de otros criterios.
Para buscar un archivo por nombre en el directorio actual, use el indicador -name seguido del nombre del archivo para buscar:
ubuntu@ubuntu18:~$ find . -name a.txt
./myfiles/a.txt
Para buscar directorios, use -type d
bandera:
ubuntu@ubuntu18:~$ find . -type d
.
./.ssh
./myfiles
./.cache
./.gnupg
./.gnupg/private-keys-v1.d
./docker
Para buscar archivos por tamaño, digamos archivos de más de 20 MB, utilice -size
bandera:
ubuntu@ubuntu18:~$ find . -size +20M
./docker/docker-ce-cli_5%3a19.03.12~3-0~ubuntu-bionic_amd64.deb
./docker/docker-ce_5%3a19.03.12~3-0~ubuntu-bionic_amd64.deb
Haga clic aquí para más información sobre la Comando Buscar de Linux.
systemctl
Ahora que systemd
has replaced SysV init process in most Linux distributions, use systemctl comando para administrar servicios y unidades systemd.
Para iniciar un servicio, por ejemplo apache2:
ubuntu@ubuntu18:~$ sudo systemctl start apache2.service
Puede dejar el sufijo de servicio.
Para detener un servicio:
ubuntu@ubuntu18:~$ sudo systemctl stop apache2
Para ver el estado del servicio, use systemctl
comando de estado. El siguiente ejemplo muestra el estado de apache2 mientras se está ejecutando:
ubuntu@ubuntu18:~$ sudo systemctl status apache2
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: active (running) since Wed 2020-08-19 11:34:04 UTC; 2s ago
Process: 25346 ExecStop=/usr/sbin/apachectl stop (code=exited, status=0/SUCCESS)
Process: 18202 ExecReload=/usr/sbin/apachectl graceful (code=exited, status=0/SUCCESS)
Process: 25536 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 25555 (apache2)
Tasks: 55 (limit: 1024)
CGroup: /system.slice/apache2.service
├─25555 /usr/sbin/apache2 -k start
├─25558 /usr/sbin/apache2 -k start
└─25559 /usr/sbin/apache2 -k start
Aug 19 11:34:04 ubuntu18 systemd[1]: Starting The Apache HTTP Server...
Aug 19 11:34:04 ubuntu18 systemd[1]: Started The Apache HTTP Server.
ufw comando
UFW – uncomplicated firewall is an easy to use frontend for iptables. It is available by default, on Ubuntu-based distributions. On CentOS, you can install ufw
del repositorio de EPEL.
Para permitir ufw:
$ sudo ufw enable
Check firewall status with ufw Estado:
$ sudo ufw status
Status: active
Predeterminado UFW policies allow all outgoing traffic and block all incoming traffic.
El siguiente comando permite el tráfico entrante en el puerto HTTP:
$ sudo ufw allow http
Rule added
Rule added (v6)
Puede denegar el tráfico en cualquier puerto. A continuación, se muestra un ejemplo para bloquear el tráfico en el puerto 21:
$ sudo ufw deny 21
Rule added
Rule added (v6)
journalctl
Uso journalctl
para ver los registros recopilados por systemd. systemd recopila el registro en una ubicación central en formato binario. Para ver estos registros:
ubuntu@ubuntu18:~$ sudo journalctl
-- Logs begin at Mon 2020-06-29 02:48:31 UTC, end at Wed 2020-08-19 15:07:59 UTC. --
Jun 29 02:48:31 ubuntu kernel: Linux version 5.3.0-1028-azure (buildd@lcy01-amd64-003) (gcc version 7.5.0 (Ubuntu
Jun 29 02:48:31 ubuntu kernel: Command line: BOOT_IMAGE=/boot/vmlinuz-5.3.0-1028-azure root=UUID=b0dd9d06-536e-41
Jun 29 02:48:31 ubuntu kernel: KERNEL supported cpus:
Jun 29 02:48:31 ubuntu kernel: Intel GenuineIntel
...
Mostly, you would prefer seeing the logs in reverse order, that is, the latest logs first:
ubuntu@ubuntu18:~$ sudo journalctl -r
-- Logs begin at Mon 2020-06-29 02:48:31 UTC, end at Wed 2020-08-19 15:10:16 UTC. --
Aug 19 15:10:16 ubuntu18 sudo[31263]: pam_unix(sudo:session): session opened for user root by ubuntu(uid=0)
Aug 19 15:10:16 ubuntu18 sudo[31263]: ubuntu : TTY=pts/1 ; PWD=/home/ubuntu ; USER=root ; COMMAND=/bin/journalc
Aug 19 15:10:11 ubuntu18 sudo[31213]: pam_unix(sudo:session): session closed for user root
Aug 19 15:07:59 ubuntu18 sudo[31213]: pam_unix(sudo:session): session opened for user root by ubuntu(uid=0)
Aug 19 15:07:59 ubuntu18 sudo[31213]: ubuntu : TTY=pts/1 ; PWD=/home/ubuntu ; USER=root ; COMMAND=/bin/journalc
Aug 19 15:07:56 ubuntu18 sudo[31183]: pam_unix(sudo:session): session closed for user root
Aug 19 15:06:47 ubuntu18 sudo[31183]: pam_unix(sudo:session): session opened for user root by ubuntu(uid=0)
...
Para ver los registros de un servicio específico, por ejemplo, use mysql -u
bandera:
ubuntu@ubuntu18:~$ sudo journalctl -u mysql
-- Logs begin at Mon 2020-06-29 02:48:31 UTC, end at Wed 2020-08-19 15:11:34 UTC. --
Aug 16 12:30:02 ubuntu18 systemd[1]: Starting MySQL Community Server...
Aug 16 12:30:03 ubuntu18 systemd[1]: Started MySQL Community Server.
Aug 19 15:03:27 ubuntu18 systemd[1]: Stopping MySQL Community Server...
Aug 19 15:03:29 ubuntu18 systemd[1]: Stopped MySQL Community Server.
matar y matar
You may need to kill a runaManera process or when you need to free some system resources. kill with -l
flag shows all the signals you can send to a process.
ubuntu@ubuntu18:~$ kill -l
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP
6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1
11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM
16) SIGSTKFLT 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP
....
Two most commonly used signals are SIGTERM AND SIGKILL. You can also use -9 for SIGKILL and -15 for SIGTERM. SIGTERM allows a process to complete before it is terminated and therefore is called soft kill. SIGKILL terminates el process inmediatamenteately. Here is an example:
List all apache2 processes
ubuntu@ubuntu18:~$ ps aux|grep apache2
root 45521 0.0 0.5 78188 4688 ? Ss Aug08 0:03 /usr/sbin/apache2 -k start
www-data 45524 0.0 0.5 830480 4816 ? Sl Aug08 0:00 /usr/sbin/apache2 -k start
www-data 45525 0.0 0.7 830480 6856 ? Sl Aug08 0:00 /usr/sbin/apache2 -k start
ubuntu 70374 0.0 0.1 14852 1040 pts/0 S+ 07:45 0:00 grep --color=auto apache2
To kill apache2 process process id 45525:
ubuntu@ubuntu18:~$ sudo kill -9 45525
Again view the list of apache2 processpor ejemplo:
ubuntu@ubuntu18:~$ ps aux|grep apache2
root 45521 0.0 0.5 78188 4688 ? Ss Aug08 0:03 /usr/sbin/apache2 -k start
www-data 45524 0.0 0.5 830480 4816 ? Sl Aug08 0:00 /usr/sbin/apache2 -k start
ubuntu 70525 0.0 0.1 14852 1052 pts/0 S+ 07:52 0:00 grep --color=auto apache2
Use killall to kill a program by name. Which means killall kills the control(parent) process and all child processes. To kill all instances of the apache2 process en el ejemplo anterior:
ubuntu@ubuntu18:~$ sudo killall apache2
Uso kill
y killall
with caution. These commands might leave the system in an unstable state.
IP
El ip
comando reemplaza ifconfig
en las distribuciones de Linux más recientes. Úselo para configurar y mostrar interfaces de red. También se utiliza para mostrar y modificar direcciones IP, rutas y objetos vecinos.
Muestra información sobre todas las interfaces de red:
ubuntu@ubuntu18:~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:0d:3a:9b:88:d6 brd ff:ff:ff:ff:ff:ff
inet 10.0.0.4/24 brd 10.0.0.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::20d:3aff:fe9b:88d6/64 scope link
valid_lft forever preferred_lft forever
Para activar o desactivar una interfaz, utilice ip link set dev seguido del nombre del dispositivo. Por ejemplo, para poner en línea la interfaz eth0:
ubuntu@ubuntu18:~$ ip link set eth0 up
Y para derribarlo:
ubuntu@ubuntu18:~$ ip link set eth0 down
date
Un comando de uso muy común, aquí exploramos algunas formas interesantes de usar este comando.
ubuntu@ubuntu18:~$ date
Tue Aug 11 07:42:49 UTC 2020
To see next Sunday’s date:
ubuntu@ubuntu18:~$ date -d 'next sunday'
Sun Aug 16 00:00:00 UTC 2020
To see last Sunday’s date:
ubuntu@ubuntu18:~$ date -d 'last sunday'
Sun Aug 9 00:00:00 UTC 2020
You can also use –date instead of -d flag:
ubuntu@ubuntu18:~$ date --date='last sunday'
Sun Aug 9 00:00:00 UTC 2020
To see date Hace 6 días:
ubuntu@ubuntu18:~$ date --date='6 days ago'
Wed Aug 5 08:06:37 UTC 2020
Date 6 días a partir de ahora:
ubuntu@ubuntu18:~$ date --date='6 days'
Mon Aug 17 08:08:37 UTC 2020
You can easily control date output format. Here is an example:
ubuntu@ubuntu18:~$ date '+%d-%B-%Y'
11-August-2020
Resumen
Usted, como administrador del sistema, mantenga el mundo infraestructura informática running. You need to solve problems, maintain and keep the systems running optimally while ensuring security.
Espero que estos comandos te sean útiles y te ayuden a hacer mejor tu trabajo.
Éstos son algunos Clientes FTP / SFTP y mejores hojas de trucos de Vim para desarrolladores y administradores de sistemas.