3 Basic Commands and Simple Shell Scripts Once you have your first Red Hat Enterprise Linux rhel


[root@rhel-instance ]# ls -m /var/



Download 1.85 Mb.
View original pdf
Page14/67
Date26.02.2024
Size1.85 Mb.
#63678
1   ...   10   11   12   13   14   15   16   17   ...   67
Pablo Iranzo Gómez, Pedro Ibáñez Requena, Miguel Pérez Colino, Scott McCarty - Red Hat Enterprise Linux 9 Administration-Packt Publishing (2022) -chap 3 82 - 180
[root@rhel-instance
]# ls -m /var/

account, adm, cache, crash, db, empty, ftp, games, gopher,
kerberos, lib, local, lock, log, mail, nis, opt, preserve, run,
spool, tmp, yp
Now, we run the command again, redirecting the output to the /root/var-files.txt file:
[root@rhel-instance
]# ls m var > /root/var-files.txt

[root@rhel-instance
]#

As we can see, no output is shown onscreen, but we will be able to find the new file in the current working directory – in this case, root, the newly created file:
[root@rhel-instance
]# ls /root

anaconda-ks.cfg var-files.txt
To seethe content of the file onscreen, we use the cat command, intended to concatenate the output for several files, but regularly used for this purpose:
[root@rhel-instance
]# cat var-files.txt

account adm, cache, crash, db, empty, ftp, games, gopher,
kerberos, lib, local, lock, log, mail, nis, opt, preserve, run,
spool, tmp, yp
We can also add to this file the content of /var/lib. First, we can list it:
[root@rhel-instance
]# ls -m /var/lib/

alternatives, authselect, chrony, dbus, dhclient, dnf, games,
initramfs, logrotate, misc, NetworkManager, os-prober,
plymouth, polkit-1, portables, private, rhsm, rpm, rpm-state,
rsyslog, selinux, sss, systemd, tpm, tuned, unbound

Understanding IO redirection on the command line
79
Now, to append this content to the /root/var-files.txt file, we use the >> operator:
[root@rhel-instance
]# ls -m /var/lib/ >> var-files.txt

[root@rhel-instance
]# cat var-files.txt

account, adm, cache, crash, db, empty, ftp, games, gopher,
kerberos, lib, local, lock, log, mail, nis, opt, preserve, run,
spool, tmp, yp
alternatives, authselect, chrony, cni, containers, dnf, fprint,

Download 1.85 Mb.

Share with your friends:
1   ...   10   11   12   13   14   15   16   17   ...   67




The database is protected by copyright ©ininet.org 2024
send message

    Main page