Useful commands for Linux

This is not intended to be a complete list, but I assure you that you will find a good part of the most common and useful commands for the Linux command console. 🙂

General Commandos

dmesg
Print the messages displayed by the kernel at startup.

depmod -a
It generates a file that contains the dependencies of the modules that are loaded for the "Kernel", that is, it is able to recognize which modules must be loaded for a third party to be used in the system.

free
Memory usage statistics.

init q
Command that reads the parameters found in inittab.

insmod
It enables ("loads") the module that is specified in the line, so that the "kernel" is able to use it. (Example: insmod ip_alias.o)

ldconfig
Updates the libraries used by the system, it is recommended to run it every time a program is installed.

lsmod
It displays the information regarding the modules that are enabled by the kernel.

mount
Allows system partitions, CD-ROMs, floppies to be read on the system. Its format: mount -t. See also / etc / fstab .ón>
smbmounton>
Similar to the mount command, except that this command is used to mount partitions in Samba .ón>
smbumounton>
Used to disable partitions activated with smbmoon>
setupon>
Presents a menu to configure various system parameters (Sound, Xwindow, Mouse ..) .on>
locateon>
Update the database that is used to find files with the locate command .ón>
staton>
It displays detailed information about the specified file such as: modification and change dates, file owner ... etc.on>
umounton>
Deactivate the partition indicated, the parameters that this command takes are similar to those of mount .ón>
uname -aon>
Complete information about the «Host» .ón>
uptimeon>
Current time, time the system has been running since the last "reboot", users connected to the server, system load in the last 1,5 and 15 minutes.
hostnameon>
The name of the «Host» .ón>
chkconfigon>
This command displays the information about the execution levels of the "scripts" located in the directory /etc/rc.d/init.dón>
on>
Code:

chkconfig --list httpd This command displays: httpd 0 ff 1 ff 2 ff 3 n 4 n 5 n 6 ff

The above indicates that when boot level 3 is used, the httpd "script" in the /etc/rc.d/init.d directory will receive the "start" argument, when running boot level 6, httpd will receive the argument "stop", etc ..

To modify towards "start" argument:

Code:

chkconfig --add --level

To modify towards the "stop" argument:

Code:

chkconfig --del --level

* It is precisely from the /etc/rc.d/rc[0-6] directories where the information it displays comes from chkconfig.

ntsysv
It is a graphical tool that has the same functionality as chkconfig, the difference is that this tool displays all the "scripts" by level, that is, if the command ntsysv –level 3 is used, the graph will show the status "stop" or "start" of all the "scripts" for the level boot 3. In the same way the following are used: ntsysv –level 5, ntsysv –level 0, etc.

As chkconfigntsysv modifies and takes the information found in the /etc/rc.d/rc[0-6 directories]

Network Environment Commands

In Network Environment 

host
Determine the IP address of a "Host", host -a displays all DNS information.

ifconfig
It allows you to configure a network interface and see its status. This is in the form ifconfig, example: ifconfig eth0

Ifup
Enables the specified interface, example: ifup eth0.

ifdown
Disable the specified interface, example: ifdown eth0.

netstat -a
All network connections originated and received by the «Host»

netstat -r
Displays the system's routing table

netstat -i
Network statistics of each interface

nslookup
Look for information in the DNS servers, example: nslookup -query = mx osomosis.com, if no parameters are specified, it enters interactive mode

ping -s 1016
It sends ping packets of 1024 bytes (header 8 bytes), while the "default" is 512.

route add
It allows adding routing tables to and from the «Host». Example: To guide all the information of the network 206.171.55.16 netmask 255.255.255.240 via the interface eth0:

Code:

route add -net 206.171.55.16 255.255.255.240 eth0

To route all traffic through a certain interface ("Default Gateway"):


Code:

route add default gw 206.171.55.51 eth0

This will send all the information through the address 206.171.55.51

route-n:
It displays the routing table of the «Host». NOTE: "IP Forwarding" must be ON in / etc / sysconfig / network, also the "kernel" must be configured for "IP Forwarding".

smbclient
It works like an FTP client, which simulates connections that will be made through Samba.

Tcpdump
Allows debugging of an interface on the host.

body parm
Check the validity of the smb.conf file used by Samba.

Commands for Process Control

Process control:

ps-aux
It displays all the system processes, with name and start time.

kill
It is used to send signals to Unix processes.
kill -HUP: Signal the numbered process to read its configuration files again.
kill -INT: Mark the process with a number, which will be interrupted.
kill -TERM: Indicates the process with a number, which must finish, unlike -KILL, this option gives the opportunity to the process to finish.
kill -STOP: Mark the process with a number, stop momentarily.
kill -CONT: Indicates the process with number, which I continued, this command is used to resume a process that was applied -STOP.
kill -KILL: Indicates the process with a number, to finish immediately, the process is ended abruptly.

killall Unlike kill, killall allows you to signal the process by name. Send the -TERM signal to the process with the specified name. NOTE: By default the signal taken by kill and killall is -TERM.

ps -l This command displays two parameters PRI and NI. The PRI parameter indicates the current priority of the process, which is calculated by the operating system, the NI value is taken into account when determining the PRI. * What is NI? : NI is called the "nice number", this number is specified by the "superuser" ("root") or owner of the process and affects the final order of the PRI, gives priority to the less gentle. Its values ​​range from -20 (less gentle = more priority) and 20 (more gentle = less priority)

nice This command specifies the NI number of each process.

nice-10 named: This would lower the priority of named by 10 units (if it was -10, it will go to -20).
nice +10 named: This would increase the priority of named by 10 units (if it was 0, it would go to +10).

snice and renice The same operation as nice, except that it uses the process number:
nice -10

& The & is used to indicate that the process should run in the background.

top This tool monitors various system resources and has a dynamic character, it shows CPU usage per process, amount of memory, time since its start, etc. vmstat It is very similar to top since it is a condensation of the system processes, so that this tool becomes dynamic, the arguments must be specified: vmstat -n

atThis command allows you to schedule certain activities at a certain time, example: at 22:00, the previous command opens a «prompt» of the form at>, on this «prompt» all the commands you want to execute are specified, in this case at 22:00, once specified, use Ctlrl -d to exit.

Once finished, the commands will be scheduled to run at the indicated time, the / var / spool / at directory contains the job.

The atq command displays the at jobs that are pending, and the atrm command

delete a job scheduled with at. See also /etc/at.deny and /etc/at.allow

crontabLike at specifies the time at which a "script" program will run, crontab has the following form: minutes hours days months end_of_week user_name statement arguments
The following example will run the oracle.pl program every half hour every day:

Code:

30 * * * * root /usr/oracle.pl

If you want to do it monthly:

Code:

01 3 1 * * root /usr/oracle.pl

The above will execute oracle.pl the first day of each month, at 3:01 AM.

To specify cron jobs, each user maintains a file in the / var / spool / cron / directory, this directory is accessed by each user with the crontab -e command

The execution of crontab is facilitated due to the / etc / crontab file that specifies crontab jobs per hour, day, week and month, in this way it only requires the user to place a file in the corresponding directories: /etc/cron.hourly | /etc/cron.daily | /etc/cron.weekly | /etc/cron.monthly

Commands for Records and System

Control of Registers «Logs» 

tail
Allows you to see the end of a file, this command is useful since the "logs" files constantly grow tail –f / var / log / messages

You can also specify the number of lines to be observed:

Code:

tail --f --line 15 / var / log / messages

This above command displays the last 15 lines of the file ("default" = 10). The –f keeps the file open so you can watch it as events are added.

System configuration 
/ usr / sbin / sndconfig: Executable used to configure the sound of the system.
/ bin / netconf: Executable used to configure Network Interfaces.

Administration Commands

sysctl
Description: Configure kernel parameters at runtime.
Examples: sysctl -a

ulimit
Description: shows the system limits (maximum open files, etc.)
Examples: ulimit

adduser
Description: add system user.
Examples: adduser pepe, adduser -s / bin / false pepe

userdel
Description: = remove user from system
Examples: userdel pepe

usermod
Description: = modify system user
Examples: usermod -s / bin / bash pepe

df
Description: = disk free. available disk space. Very useful.
Examples: df, df -h

uname
Description: = unix name. Information about the type of unix we are in, kernel, etc.
Examples: uname, uname -a

netstat
Description: information about active network connections.
Examples: netstat, netstat -ln, netstat -l, netstat -a

ps
Description: = proccess all information about running processes.
Examples: ps, ps -axf, ps -A, ps -auxf

free
Description: shows the status of the RAM and SWAP.
Examples: free

ping
Description: network tool to check among other things if we reach a remote host.
Examples: ping www.rediris.es

traceroute
Description: network tool that shows us the path needed to get to another machine.
Examples: traceroute www.rediris.es

du
Description: = disk use. disk usage. Shows the space that is occupied on the disk.
Examples: du *, du -sH / *, du -sH / etc

ifconfig
Description: = interface config. configuration of network interfaces, modems, etc.
Examples: ifconfig, ifconfig eth0 ip netmask 255.255.255.0

road.
Description: manages routes to other networks.
Examples: route, route -n

iptraf
Description: displays ALL IP, UDP, ICMP network traffic in a console application.
It allows the use of filters, and it is VERY USEFUL for diagnosing and debugging firewalls
Examples: iptraf

Tcpdump
Description: dumps the content of network traffic.
Examples: tcpdump, tcpdump -u

lsof
Description: shows the files (libraries, connections) used by each process
Examples: lsof, lsof -i, lsof | grep file

lsmod
Description: Shows the kernel modules that are loaded.
Examples: lsmod

modprobe
Description: Try to install a module, if you find it, install it but temporarily.
Examples: modprobe ip_tables, modprobe eepro100

rmmod
Description: Remove kernel modules that are loaded
Examples: rmmod

sniffit
Description: Sniffer or snooper of all network traffic. It is not usually installed by default.
Examples: sniffit -i

Others

ls
Description: = list. list directory contents.
Examples: ls, ls -l, ls -fl, ls –color

cp
Description: = copy. copy files / directories.
Examples: cp -rfp / tmp directory, cp file new_file

rm
Description: = remove. delete files / directories.
Examples: rm -f file, rm -rf directory, rm -i file

mkdir
Description: = make dir. create directories.
Examples: mkdir directory

rmdir
Description: = remove dir. delete directories, they must be empty.
Examples: rmdir directory

mv
Description: = move. rename or move files / directories.
Examples: mv directory directory, mv file new_name, mv file a_directory

data
Description: system date management, can be viewed and set.
Examples: date, date 10091923

history
Description: shows the history of commands entered by the user.
Examples: history | more

more
Description: shows the content of a file with pauses every 25 lines.
Examples: more file

grep
Description: filters the contents of a file.
Examples: cat file | grep string

cat
Description: shows all the content of a file without any pause.
Examples: cat file

chmod
Description: change the permissions for reading / writing / executing files / directories.
Examples: chmod + r file, chmod + w directory, chmod + rw directory -R, chmod -r file

chown
Description: = change owner. change user permissions: group of files / directories.
Examples: chown root: root file, chown pello: users directory -R

tar
Item Description: = Tape ARchiver. file archiver.
Examples: tar cvf file.tar directory, tar xvf file.tar, tar zcvf file.tgz directory, tar zxvf file.tgz

gunzip
Description: ZIP compatible decompressor.
Examples: gunzip file

rpm
Description: Redhat package manager. To install or update system software.
Examples: rpm -i package.rpm, rpm -qa program, rpm –force package.rpm, rpm -q –info program

mount
Description: mount hard drives, floppy, cdrom.
Examples: mount / dev / hda2 / mnt / lnx, mount / dev / hdb1 / mnt -t vfat

umount
Description: disassemble units.
Examples: umount / dev / hda2, umount / mnt / lnx

wget
Description: program to download files via http or ftp.
Examples: wget 
http://www.rediris.es/documento.pdf

lynx
Description: web browser with ftp options, https.
Examples: lynx 
www.ibercom.com, lynx–source http://www.ibercom.com/script.sh | sh

ftp
Description: customer ftp.
Examples: ftp 
ftp.ibercom.com

whois
Description: domain whois.
Examples: whois 
ibercom.com

who
Description: Shows the system users who have logged in.
Examples: who, w, who am i

mail
Description: sending and reading email.
Examples: mail 
pepe@ibercom.com <file, mail -v pepe@ibercom.com <file
Black
Description: sorts the content of a file.
Examples: cat / etc / numbers | sort, ls | sort

ln
Description: = link. to create links, shortcuts.
Examples: ln -s / directory link

tail
Description: shows the end (10 lines) of a file.
Examples: tail -f / var / log / maillog, tail -100 / var / log / maillog | more

head
Description: shows the header (10 lines) of a file.
Examples: head file, head -100 / var / log / maillog | more

fillet
Description: it tells us what type a file is.
Examples: file file, file *

Source: Crystalb


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Christopher said

    It's always good to have these types of lists on hand 🙂 Thank you

  2.   crafty said

    I think it would be an important command when programming when we want our PC to turn off.
    I'm talking about the command:

    shutdown

    What information can you provide us?

    regards

  3.   Saito Mordraw said

    As always a great entry, direct to favorites (I had not commented before because I burned my computer and until I bought another…. XD)

  4.   Jose Antonio said

    Hello, very good, I have already read here that I look for my solutions by
    Internet but I can't find anything, surely it will be me that I don't know
    search ... I am studying Linux for the first time in high school and at
    install Ubuntu 12.10 I enter the terminal to practice what I learned and
    I can't do anything I can't be root or do a mkdir in
    home… ..ect. Can someone guide me with a tutorial or page
    I would be very grateful .... thank you

  5.   José Antonio said

    I have found a very interesting tutorial in case the sound goes away every 10 minutes in Linux:

    https://pcfix3r.wordpress.com/el-sonido-se-va-cada-10-minutos-en-linux-mint-sound-goes-off-after-10-minutes/

  6.   José Antonio said

    If the sound goes away when the screensaver is activated, that is, every 10 minutes, the solution at least in Linux Mint comes in the following blog:

    https://pcfix3r.wordpress.com/el-sonido-se-va-cada-10-minutos-en-linux-mint-sound-goes-off-after-10-minutes/

    And if the sound is also deactivated after suspending or hibernating the solution is the following:

    https://pcfix3r.wordpress.com/sin-sonido-tras-hibernar-o-supsender-no-sound-after-resume-in-linux-mint-ubuntu-lubuntu/

  7.   roni said

    Thank you very much, I was looking for the same thing from the AT command to leave some commands programmed ... thank you.

  8.   DC said

    Excellent! info, a question between TOP and HTOP differences?

    thanks!