Friday, January 03, 2014: System commands for Linux are not the most difficult, but when you've been in front of the command line, it can be easy to forget the right command. Keep this list handy as a reference for when you need them!
1. uptime: This command shows how long the system has been running. It also shows the number of users that are logged into the system along with the load average for intervals of one, five and 15 minutes.
# uptime
Output: 08:16:26 up 22 min, 1 user, load average: 0.00, 0.03, 0.22
2. w: This command shows you the users that are currently logged in to the system along with the processes they are running and load averages. You will also get the login name, remote host, tty name, idle time, login time, JCPU, PCPU, command and processes.
# w
Output: 08:27:44 up 34 min, 1 user, load average: 0.00, 0.00, 0.08
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
tecmint pts/0 192.168.50.1 07:59 0.00s 0.29s 0.09s w
Modify the command using these options:
-h : header entries.
-s : don’t show JCPU and PCPU.
-f : Removes from field.
-V : (upper letter) – Shows versions.
3. users: This command shows you the users that are currently logged in to the system. It doesn’t have any parameters.
4. who: You will use this command to get the username, date, host information and time. It is quite similar to the w command except that who doesn’t show the users’ processes.
# who
Output: xyz pts/0 2012-09-18 07:59 (192.168.50.1)
You can modify the command with the following:
-b : Date and time of last system reboot.
-r : Current runlet.
-a, –all : Show all information cumulatively.
5. whoami: You can also use this command as who am i. It will print the name of the current user of the system. It returns ‘root’ when you are logged in as root using the sudo command.
# whoami
Output: xyz
6. ls: This command will display the list of files in a readable format. A format that humans can read that is.
# ls -l
Output: total 114
dr-xr-xr-x. 2 root root 4096 Sep 18 08:46 bin
dr-xr-xr-x. 5 root root 1024 Sep 8 15:49 boot
If you need to sort the files as per the last modified time, then use this:
# ls -ltr
Output: total 40
-rw-r--r--. 1 root root 6546 Sep 17 18:42 install.log.syslog
-rw-r--r--. 1 root root 22435 Sep 17 18:45 install.log
-rw-------. 1 root root 1003 Sep 17 18:45 anaconda-ks.cfg
7. crontab: This command lists the scheduled jobs for the current user.
# crontab -l
Output: 00 10 * * * /bin/ls >/ls.txt
8. Less Command: This command is used to quickly view a file. You can use ‘q’ to quit and page up and page down to go up and down on the window.
# less install.log
Output: Installing setup-2.8.14-10.el6.noarch
warning: setup-2.8.14-10.el6.noarch: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Installing filesystem-2.4.30-2.1.el6.i686
Installing ca-certificates-2010.63-3.el6.noarch
Installing xml-common-0.6.3-32.el6.noarch
Installing tzdata-2010l-1.el6.noarch
Installing iso-codes-3.16-2.el6.noarch
9. more: This is the command that you use when you want to view a file in detail. It also shows a percentage. You can use page up, page down and ‘q’ just like you did with the less command.
# more install.log
Output: Installing setup-2.8.14-10.el6.noarch
warning: setup-2.8.14-10.el6.noarch: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Installing filesystem-2.4.30-2.1.el6.i686
Installing ca-certificates-2010.63-3.el6.noarch
Installing xml-common-0.6.3-32.el6.noarch
Installing tzdata-2010l-1.el6.noarch
Installing iso-codes-3.16-2.el6.noarch
--More--(10%)
10. cp: Use this command to copy files from the source to the destination while using the same mode.
# cp -p fileA fileB
If a file is being overwritten then you will be prompted.
# cp -i fileA fileB
11. mv: Use this command when you want to rename a file. Using the –I modifier will prompt you if something is being overwritten.
# mv -i fileA fileB
12. cat: Use this command when you want to view more than one files at the same time.
# cat fileA fileB
In order to view a file that doesn’t fit in one screen, use the more or less commands along with cat.
# cat install.log | less
# cat install.log | more
Fonte= 12 Linux Commands That You Should Keep As Reference
Linux Tech Hacks
Your Linux tech hacks and Tips
Assinar:
Postar comentários (Atom)
Marcadores
10 Coisas e mais que o 'apt' pode te ajudar!
(1)
16 Ferramentas Poderosas Para Usuários Linux
(1)
25 melhores aplicativos para Linux
(1)
Alguns Comandos Para conseguir Informacao do Sistema em Linux
(1)
Comandos engraçados que voce talvez possa NÃO conhecer!
(1)
Linux se tornará uma força majoritária em jogos
(1)
Por Que a Valve Quer Portar 2500 Jogos Para Linux?
(1)
Steam Box da Valve rodará Linux
(1)
Um pouco sobre o Nmap 6.0
(1)
Você usa sudo? aprenda o básico
(1)
init system
(1)
launchd
(1)
macosx
(1)
smf
(1)
solaris
(1)
systemd
(1)
Nenhum comentário:
Postar um comentário