En este apartado os prepararé una lista de comandos Linux útiles para la asignatura. También podéis echar un ojo a la zona de Referencias donde encontraréis enlaces a documentación sobre Linux.
También podéis consultar alguna de las Quick Reference Cards que os dejo aqui:
bin boot dev etc home lib mnt opt proc root sbin tmp usr var / \ | user1 user2 log
devices
) del sistemaroot
optional
)root
santi@zenbook:$ uptime 09:44:52 up 5 min, 2 users, load average: 0.00, 0.05, 0.03
santi@zenbook:$ top
Mostrará, ocupando toda la pantalla, la siguiente información (se sale pulsando la tecla q
)
top - 09:45:09 up 6 min, 2 users, load average: 0.00, 0.05, 0.02 Tasks: 69 total, 1 running, 68 sleeping, 0 stopped, 0 zombie %Cpu(s): 0.0 us, 0.3 sy, 0.0 ni, 99.3 id, 0.3 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 2052640 total, 1824764 free, 43292 used, 184584 buff/cache KiB Swap: 2095100 total, 2095100 free, 0 used. 1865816 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1304 daw 20 0 42692 3620 3064 R 0.3 0.2 0:00.01 top 1 root 20 0 57056 6820 5268 S 0.0 0.3 0:00.88 systemd 2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd 3 root 20 0 0 0 0 S 0.0 0.0 0:00.02 ksoftirqd/0 5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H 7 root 20 0 0 0 0 S 0.0 0.0 0:00.08 rcu_sched 8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh 9 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/0 10 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 lru-add-drain 11 root rt 0 0 0 0 S 0.0 0.0 0:00.00 watchdog/0 12 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cpuhp/0 . . . . . .
santi@zenbook:$ uname -a Linux despliegue-daw 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u5 (2017-09-19) x86_64 GNU/Linux
santi@zenbook:$ who daw tty1 Oct 7 09:39 daw pts/0 Oct 7 09:44 (192.168.1.3)
who
) y alguna información extra al respectosanti@zenbook:$ w 09:55:54 up 16 min, 2 users, load average: 0.00, 0.00, 0.00 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT daw tty1 - 09:39 11:14 0.14s 0.09s -bash daw pts/0 192.168.1.3 09:44 1.00s 0.10s 0.00s w
santi@zenbook:$ df -h Filesystem Size Used Avail Use% Mounted on udev 992M 0 992M 0% /dev tmpfs 201M 3.0M 198M 2% /run /dev/sda1 5.9G 917M 4.7G 17% / tmpfs 1003M 0 1003M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 1003M 0 1003M 0% /sys/fs/cgroup tmpfs 201M 0 201M 0% /run/user/1000
apache
)santi@zenbook:$ ps aux | grep apache root 397 0.0 0.2 75608 4316 ? Ss 09:39 0:00 /usr/sbin/apache2 -k start www-data 401 0.0 0.1 364768 4068 ? Sl 09:39 0:00 /usr/sbin/apache2 -k start www-data 402 0.0 0.1 364768 4072 ? Sl 09:39 0:00 /usr/sbin/apache2 -k start daw 1378 0.0 0.0 12756 972 pts/0 S+ 09:55 0:00 grep apache
/usr/local
)santi@zenbook:$ ls /usr/local bin etc games include lib man sbin share src
santi@zenbook:$ ls -la /usr/local total 40 drwxrwsr-x 10 root staff 4096 Oct 4 23:06 . drwxr-xr-x 10 root root 4096 Oct 4 23:06 .. drwxrwsr-x 2 root staff 4096 Oct 4 23:06 bin drwxrwsr-x 2 root staff 4096 Oct 4 23:06 etc drwxrwsr-x 2 root staff 4096 Oct 4 23:06 games drwxrwsr-x 2 root staff 4096 Oct 4 23:06 include drwxrwsr-x 4 root staff 4096 Oct 4 23:11 lib lrwxrwxrwx 1 root staff 9 Oct 4 23:06 man -> share/man drwxrwsr-x 2 root staff 4096 Oct 4 23:06 sbin drwxrwsr-x 7 root staff 4096 Oct 4 23:11 share drwxrwsr-x 2 root staff 4096 Oct 4 23:06 src
santi@zenbook:$ cd mis_trabajos
santi@zenbook:$ pwd /home/santi/mis_trabajos
santi@zenbook:$ mkdir mis_trabajos
mis_trabajos
)santi@zenbook:$ rmdir mis_trabajos
santi@zenbook:$ cp trabajo.pdf trabajos/
santi@zenbook:$ cp -r trabajos/ mas_trabajos/
santi@zenbook:$ mv trabajo.pdf trabajos/
santi@zenbook:$ mv trabajo.pdf mi_trabajo.pdf
santi@zenbook:$ rm trabajos/mitrabajo.pdf
santi@zenbook:$ rm -rf trabajos/
santi@zenbook:$ tar cvzf mis_trabajos.tar.gz mis_trabajos/
santi@zenbook:$ tar xvzf mis_trabajos.tar.gz
/etc/apache2/apache2.conf
)santi@zenbook:$ cat /etc/apache2/apache2.conf
/var/log/apache2/error.log
)santi@zenbook:$ tail /var/log/apache2/error.log
/var/log/apache2/error.log
)santi@zenbook:$ tail -n 100 /var/log/apache2/error.log
php
) entre las últimas 100 líneas de un fichero (en este caso /var/log/apache2/error.log
)santi@zenbook:$ tail -n 100 /var/log/apache2/error.log | grep 'php'
fichero_ejecutable.sh
)santi@zenbook:$ chmod u+x fichero_ejecutable.sh
fichero_ejecutable.sh
)santi@zenbook:$ chmod a+rx fichero_ejecutable.sh
fichero_ejecutable.sh
)santi@zenbook:$ chmod ug+rx fichero_ejecutable.sh
fichero_ejecutable.sh
)santi@zenbook:$ chmod g-r fichero_ejecutable.sh
mi_trabajo.pdf
santi@zenbook:$ chown santi.santi mi_trabajo.pdf
otro_usuario
)santi@zenbook:$ sudo adduser otro_usuario
otro_usuario
)santi@zenbook:$ sudo userdel -r otro_usuario
santi@zenbook:$ passwd
santi
al grupo sysadmin
)santi@zenbook:$ sudo adduser santi sysadmin
root
)santi@zenbook:$ sudo passwd otro_usuario
santi@zenbook:$ su Password: root@zenbook:$ |
santi@zenbook:$ sudo ifconfig
192.168.1.3
)santi@zenbook:$ ping 192.168.1.3 PING 192.168.1.3 (192.168.1.3) 56(84) bytes of data. 64 bytes from 192.168.1.3: icmp_seq=1 ttl=64 time=0.161 ms 64 bytes from 192.168.1.3: icmp_seq=2 ttl=64 time=0.327 ms 64 bytes from 192.168.1.3: icmp_seq=3 ttl=64 time=0.275 ms 64 bytes from 192.168.1.3: icmp_seq=4 ttl=64 time=0.345 ms 64 bytes from 192.168.1.3: icmp_seq=5 ttl=64 time=0.305 ms 64 bytes from 192.168.1.3: icmp_seq=6 ttl=64 time=0.274 ms ^C --- 192.168.1.3 ping statistics --- 6 packets transmitted, 6 received, 0% packet loss, time 5044ms rtt min/avg/max/mdev = 0.161/0.281/0.345/0.060 ms
santi@zenbook:$ sudo /etc/init.d/networking restart
santi@zenbook:$ sudo dhclient
santi@zenbook:$ sudo service apache2 restart
santi@zenbook:$ sudo shutdown -r now
santi@zenbook:$ sudo reboot
santi@zenbook:$ sudo shutdown -h now
apache2
)santi@zenbook:$ sudo apt-get install apache2
phpmyadmin
)santi@zenbook:$ sudo dpkg-reconfigure phpmyadmin
apache2
)santi@zenbook:$ sudo apt-get remove apache2 --purge
santi@zenbook:$ dpkg -l Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Architecture Description +++-=============================-==============================-============-====================== ========================================================= ii adduser 3.115 all add and remove users a nd groups ii apache2 2.4.25-3+deb9u3 amd64 Apache HTTP Server ii apache2-bin 2.4.25-3+deb9u3 amd64 Apache HTTP Server (mo dules and other binary files) ii apache2-data 2.4.25-3+deb9u3 all Apache HTTP Server (co mmon files) ii apache2-utils 2.4.25-3+deb9u3 amd64 Apache HTTP Server (ut ility programs for web servers) ii apt 1.4.7 amd64 commandline package ma nager ii apt-listchanges 3.10 all package change history notification tool ii apt-utils 1.4.7 amd64 package management rel ated utility programs ii aspell 0.60.7~20110707-3+b2 amd64 GNU Aspell spell-check er . . . . . .
apache2
)santi@zenbook:$ apt-cache show apache2
santi@zenbook:$ sudo apt-get install -f
apache2
)santi@zenbook:$ sudo apt-get install --reinstall apache2
santi@zenbook:$ sudo apt-get update
santi@zenbook:$ sudo apt-get upgrade
ls
(se sale pulsando la letra q
)santi@zenbook:$ man ls LS(1) User Commands LS(1) NAME ls - list directory contents SYNOPSIS ls [OPTION]... [FILE]... DESCRIPTION List information about the FILEs (the current directory by default). Sort entries alpha- betically if none of -cftuvSUX nor --sort is specified. Mandatory arguments to long options are mandatory for short options too. -a, --all do not ignore entries starting with . -A, --almost-all do not list implied . and .. --author with -l, print the author of each file . . . . . .
ls
en este caso)santi@zenbook:$ ls --help Usage: ls [OPTION]... [FILE]... List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor --sort is specified. Mandatory arguments to long options are mandatory for short options too. -a, --all do not ignore entries starting with . -A, --almost-all do not list implied . and .. --author with -l, print the author of each file -b, --escape print C-style escapes for nongraphic characters --block-size=SIZE scale sizes by SIZE before printing them; e.g., '--block-size=M' prints sizes in units of 1,048,576 bytes; see SIZE format below -B, --ignore-backups do not list implied entries ending with ~ -c with -lt: sort by, and show, ctime (time of last modification of file status information); with -l: show ctime and sort by name; . . . . . .
© 2017 Santiago Faci