INFORMATICS

The Best

list of the most commonly used Linux commands

Inicio desactivadoInicio desactivadoInicio desactivadoInicio desactivadoInicio desactivado

This article provides a list of the most commonly used Linux commands with their examples for easy learning.

It's important to note that some commands are "distribution-based" - they can only be found on certain distributions.

Content:

adduser agetty alias anacron apropos apt apt-get aptitude arch arp
at atq atrm awk batch basename bc bg bzip2 cal
cat chgrp chmod chown cksum clear cmp comm cp date
dd df diff dir dmidecode du echo eject env exit
expr factor find free grep groups gzip gunzip head history
hostname hostnamectl hwclock hwinfo id ifconfig ionice iostat ip iptables
iw iwlist kill killall kmod last ln locate login ls
lshw lscpu lsof lsusb man md5sum mkdir more mv nano
nc netstat nice nmap nproc openssl passwd pidof ping ps
pstree pwd rdiff-backup reboot rename rm rmdir scp pstree pwd
rdiff-backup reboot rename rm rmdir scp shutdown sleep sort split
ssh stat su sudo sum tac tail talk tar tee
time top touch tr uname uniq uptime user vi w
wall watch wc wget whatis which who whereis xargs yes
zdiff zip zz

 

 

adduser/addgroup command
The adduser and addgroup commands are used to add a user and group to the system according to the default configuration specified in the /etc/adduser.conf file.

adduser username
addgroup group_name

 

agetty command
A program that manages physical or virtual terminals. As soon as it detects a connection, it opens the tty port, asks for a username, and invokes the /bin/login command.

Agetty is a Linux getty replacement:

agetty -L 9600 ttyS1 vt100

 

alias command
Built-in command shell to create aliases (shortcuts) for the Linux command on the system. This is useful for creating new custom commands from existing Shell/Linux commands (including options):

alias home = 'cd /home/user'

the command will create an alias called home for the /home/user directory, so when you type home at the terminal prompt it puts you in the /home/user directory

 

anacron command
A Linux tool used to run commands periodically at a frequency defined in days, weeks, and months.

Unlike the cron command, it assumes that the system will not run continuously, so if a scheduled task is to run when the system is turned off, it will run after the device is turned on.

 

apropos command
Used to find and display a short help page for a command or program

apropos adduser

 

apt command
Relatively new higher level package manager for Debian/Ubuntu systems

apt update

 

apt-get command
Package manager for Debian/Ubuntu. Used to install, remove and update both software packages and the system as a whole

apt-get update

 

aptitude command
A powerful interface to the Debian/Linux package management system. Like apt-get and apt, it can be used to install, remove, and update both software packages and the system as a whole.

 

arch command
A simple command to display the machine's architecture or hardware name (similar to uname -m ).

 

arp command
A protocol that displays the IP and MAC addresses of neighbor nodes in an IPv4 network.

arp-scan --interface=eth0 --localnet

 

at command
The command is used to schedule tasks to be performed in the future. This is an alternative to cron and anacron, however it runs a task once in a certain future without editing any configuration files:

echo "shutdown -h now" | at-m 22:55

 

atq command
The atq command is used to view jobs in the command queue.

 

atrm command
Used to withdraw/delete jobs (indicated by their job number) from the command queue.

atrm 2

 

awk command
A powerful programming language designed for word processing and commonly used as a data mining and reporting tool

awk '// {print}' /etc/hosts

 

batch command
Used to schedule tasks to run in the future, similar to the at command.

 

basename command
Prints the filename without preceding directory names.

 

bc command
CLI calculator.

echo 11.05 + 17.02 | bc

 

bg command
Used to send a process to the background.

 

bzip2 command
Used to compress or decompress files.

bzip2 -z filename #Compress
bzip2 -d filename.bz2 #Decompress

 

cal command
Displays a calendar

 

cat command
Used to view the contents of a file or concatenate files or data.

cat file.txt

 

chgrp command
Used to change group ownership of a file. Specify the new group name as the first argument and the file name as the second argument.

chgrp www-data-users.txt

 

chmod command
The chmod command is used to change or update the permissions of a file.

chmod +x file.txt

 

chown command
Changes or updates user and group permissions on a file or directory.

chmod -R www-data: www-data /var/www/html

 

cksum command
Used to display the CRC checksum and number of bytes of a file

cksum file.txt

 

clear command
Allows you to clear the terminal screen.

 

cmp command
Performs a byte-by-byte comparison of two files.

cmp file1 file2

 

comm command
Used to compare two sorted files in turn.

comm file1 file2

 

cp command
Used to copy files and directories from one location to another.

cp /home/folder1/file1 /home/folder2/

 

date command
Displays or sets the system date and time.

date
date --set="9 Dec 2017 21:00:00"


dd command
Used to copy files, convert and format them according to the flags specified on the command line. It can strip headers, extract parts of binary files, and so on.

dd if=/home/folder1/file.txt of=/dev/sdc1 bs=512M; sync

 

df command
Used to display the used file system space.

df-h

 

diff command
Used to compare two files line by line. Can also be used to determine the difference between two directories

diff file1 file2

 

dir command
Works like the ls command, it lists the contents of a directory.

 

dmidecode command
A tool to extract information about the hardware of any Linux system. It displays the contents of the computer's DMI table (SMBIOS) in an easy-to-read format for easy retrieval.

 

du command
Used to display the disk space of files in a directory.

du /home/

 

echo command
Displays the specified text.

 

eject command
Used to eject removable media.

 

env command
Displays environment variables.

 

exit command
Used to exit the shell.

 

expr command
Used to evaluate an expression.

expr 20 + 30

 

factor command
Used to display prime coefficients of a number.

 

find command
Allows you to search for files in a directory, as well as in its subdirectories.

 

free command
Shows system RAM and SWAP usage

 

grep command
Searches files for the given pattern.

grep 'text' file.txt

 

groups command
Displays the names of the groups the user is a part of.

 

gzip command
Allows you to compress files into .gz format

gzip file.txt
cat file1 file2 | gzip > file.gz

 

gunzip command
Recovers files compressed with the gzip command.

 

head command
Used to display the first lines (10 lines by default) of the specified file.

head /home/file.txt

 

history command
Used to display previously used commands or to get information about a command the user is executing.

 

hostname command
Used to display or set the Linux system hostname.

 

hostnamectl command
Manages the system host name under systemd and is used to display or change the system host name and any related settings.

hostnamectl set-hostname NAME

 

hwclock command
A tool to manage the system hardware clock.

hwclock --set --date 07/27/2017

 

hwininfo command
Used to test hardware present by Linux.

 

command id
Displays user or group information for the current or specified username.

 

ifconfig command
The ifconfig command is used to configure how to view and manage the network interfaces of Linux systems.

sudo ifconfig eth0 up
sudo ifconfig eth0 down
sudo ifconfig eth0 192.168.1.1

 

ionice command
Used to specify or view the scheduled class and process priority.

 

iostat command
Used to display CPU and IO statistics for devices and partitions.

 

ip command
Used to display, manage routing, devices, policy routing, and tunnels. Replacing ifconfig.

ip addr add 192.168.1.1 dev eth0

 

iptables command
Terminal-based firewall to control incoming and outgoing traffic through a set of custom table rules.

iptables -A INPUT -s xxx.xxx.xxx.xxx -j DROP

 

iw command
Used to manage wireless devices and their configuration.

 

iwlist command
Displays detailed wireless information from the wireless interface.

 

kill command
Used to kill a process using its PID.

 

killall command
Used to kill a process by its name.

 

kmod command
Used to manage Linux kernel modules.

 

command last
Displays a list of the most recently registered users.

 

ln command
Used to create a symbolic link.

ln -s /usr/bin/lscpu cpuinfo

 

locate command
Used to search for a file by name.

 

login command
Used to create a new session with the system. You will be prompted for a username and password to log in.

 

ls command
Used to display the contents of a directory. analog dir.

 

lsw command
It is a tool for obtaining detailed information about the hardware configuration of a machine.

 

lscpu command
Displays information about the CPU architecture.


lsof command
Displays files opened by processes. To view files opened by a specific user's processes:

lsof -u username

lsusb command
Shows information about the USB buses in the system and the devices connected to them.

 

man command
Used to display help for a command or program.

 

md5sum command
Calculates the MD5 of the specified file

 

mkdir command
Used to create one or more directories.

 

more command
Allows you to view long text files one screen at a time.

 

mv command
Used to rename or move files or directories.

 

nano command
Small, free and handy text editor for Linux.

 

nc/netcat command
Used to perform an operation related to TCP, UDP sockets, such as opening TCP connections, sending UDP packets, listening or port scanning. The below command will help us to know if port 22 is open on host 192.168.1.1.

nc -zv 192.168.1.1 22

 

netstat command
Displays information about the network subsystem (network connections, routing tables, interface statistics, masquerade connections, and multicast memberships).

 

nice command
Used to display or change the nice priority value. Executes a command with a changed priority. The nice priority (integer) of the process is used by the OS kernel process scheduler when allocating processor time between processes. The following command starts the tar process by setting the nice value to 10:

nice -10 tar -czf home.tar.bz2 /home/*

 

nmap command
A powerful tool for open scanning and security checks. Designed for quick scanning of both large networks and individual nodes. The following example will check open ports on all hosts on the specified network:

nmap -sV 192.168.1.0/24

 

nproc command
Shows the number of processor cores used to process the process. The output may show less than what is available in the system.

 

openssl command
Command line tool for using various cryptographic operations of the OpenSSL library. The example below will create an archive of all files in the current directory and encrypt the contents of the archive file:

tar-czf-* | openssl enc -e -aes256 -out backup.tar.gz

 

passwd command
Used to create or update passwords for user accounts.

 

pidof command
Displays the process ID of the running program or command.

 

ping command
Used to determine connectivity between network nodes.

 

ps command
Shows information about active processes running on the system. The example below will show the top 10 processes consuming the most RAM and CPU.

ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head

 

pstree command
Displays running processes in a tree view.

 

pwd command
Displays the name of the current/working directory.

 

rdiff backup command
Local and remote incremental backup script written in Python.

rdiff-backup /home/server.backup


reboot command
Used to stop, shutdown, or reboot a node.

 

rename command
Used to rename one or more files. The above example renames all txt files in a folder to html.

rename 's/\.txt$/\.html/' *.txt

 

rm command
Used to delete files or directories.

rm file1
rm -rf my-files

 

rmdir command
Allows you to remove empty directories.

 

scp command
Allows you to securely copy files between nodes on a network.

scp ~/names.txt Esta dirección de correo electrónico está siendo protegida contra los robots de spam. Necesita tener JavaScript habilitado para poder verlo..1.1:/root/names.txt

 

shutdown command
Sets the time during which the system will be turned off.

 

sleep command
Used to delay or pause a command for a specified amount of time.

check.sh; sleep5; sudo apt update

 

sort command
Used to sort lines of text in specified files.

 

split command
Used to split a large file into smaller pieces.

 

ssh command
An application for remote access and execution of commands on a remote computer.

ssh Esta dirección de correo electrónico está siendo protegida contra los robots de spam. Necesita tener JavaScript habilitado para poder verlo..1.1

 

stat command
Used to display the status of a file or file system.

 

su command
Used to switch user or superuser.

 

sudo command
Allows a system user to run a command as root.

 

sum command
Used to display the checksum and number of blocks for each specified file on the command line.

 

tac command
Merges and displays files in reverse order.

 

tail command
Used to display the last 10 lines of a file.

 

talk command
Used to communicate with another user of the system or network. To talk to a user on the same computer, use your login name to talk to a user on another computer using user@host.

 

tar command
Utility for archiving and unzipping files.

tar -xvzf filename.tar.gz

 

tee command
Writes the output of a command to a file.

 

time command
Starts programs and summarizes system resource usage.

time wc /etc/hosts

 

top command
Displays all processes on the system with RAM and CPU usage and provides a dynamic real-time view.

 

touch command
Changes the timestamps of a file. It can also be used to create a file.

touch file.txt

 

tr command
Used to change or remove characters from stdin and write the result to stdout.

 

uname command
Displays system information such as operating system, host kernel name, version and release, etc.

 

uniq command
Displays or skips duplicate lines from input or output. To specify the number of occurrences of a string, use the -c option.

 

uptime command
Displays how long the system has been running, the number of registered users and the average system load.

 

user command
Shows the usernames of the users who are currently logged in.

 

vim/vi command
Text editor for Unix-like operating systems.

 

w command
Displays system uptime, loads averages and information about users currently on the machine and their processes.

 

wall command
Used to display a message to all system users.

 

watch command
Runs the program repeatedly while its output is displayed in full screen mode. It can also be used to view changes to a file or directory. The following example shows how to view the contents of a directory:

watch -d ls -l

 

wc command
Used to display newline, word, and byte for each specified file, and the total for many files.

 

wget command
A utility used to download files from the Internet in non-interactive mode.

 

whatis command
Performs searches and displays quick or online command guides.

 

which command
Displays the absolute path(s) of files (or possibly links) that will be executed in the current environment.

 

who command
Shows information about users who are currently logged in.

 

whereis command
Helps us find binary, source files for commands.

 

xargs command
A utility for reading elements from standard input separated by spaces (protected by double or single quotes or backslashes) or other characters, and executes the entered command.

 

command yes
Used to display a line multiple times until it is terminated or killed with Ctrl+C.

 

zcmp / zdiff command
Utilities used to compare compressed files.

 

zip command
Utility for archiving and unzipping files.

 

command zz
It is an alias for the fasd command line tool, which provides fast file and directory access on Linux. It is used to quickly and interactively enter cd into a previously accessible directory.

How to make disk image with dd on Linux

Inicio desactivadoInicio desactivadoInicio desactivadoInicio desactivadoInicio desactivado

How to make disk image with dd on Linux

How to clone an entire hard disk

The syntax is as follow to make disk image with dd:
dd if=/dev/input/DEVICE-HERE of=/dev/OUTPUT/DEVICE-HERE bs=64K conv=noerror,sync
To clone /dev/sdc (xxxG) to /dev/sdd (xxxG) in Linux, enter:
dd if=/dev/sdc of=/dev/sdd bs=64K conv=noerror,sync

Where,

  1. if=/dev/file : Input device/file.
  2. of=/dev/file : Output device/file.
  3. bs=64k : Sets the block size to 64k. You can use 128k or any other value.
  4. conv=noerror : Tell dd to continue operation, ignoring all read errors.
  5. sync : Add input blocks with zeroes if there were any read errors, so data offsets stay in sync.

How to clone a partition and make disk image with dd

To clone /dev/sdc1 to /dev/sdd1 with dd and create an image, enter:
dd if=/dev/sdc1 of=/dev/sdd1 bs=128K conv=noerror,sync

Making disk image with dd using live CD/DVD or USB pen drive

You can boot from a live cd or USB pen drive. Once booted, make sure no partitions are mounted from the source hard drive disk. You can store disk image on an external USB disk. The syntax is as follows
dd if=/dev/INPUT/DEVICE-NAME-HERE conv=sync,noerror bs=64K | gzip -c > /path/to/my-disk.image.gz
In this example, create disk image for /dev/da0 i.e. cloning /dev/da0 and save in the current directory:
dd if=/dev/da0 conv=sync,noerror bs=128K | gzip -c > centos-core-7.gz

https://www.cyberciti.biz/media/new/faq/2016/08/freebsd-dd-demo-300x52.jpg 300w" alt="Fig.01: dd command in action" width="599" height="104" class="size-full wp-image-145587 entered lazyloaded" style="margin: 0px auto 19px; padding: 0px; word-break: break-word; border: 0px; max-width: 100%; height: auto; display: block;" aria-describedby="caption-attachment-145587" data-lazy-srcset="https://www.cyberciti.biz/media/new/faq/2016/08/freebsd-dd-demo.jpg 599w, https://www.cyberciti.biz/media/new/faq/2016/08/freebsd-dd-demo-300x52.jpg 300w" data-lazy-sizes="(max-width: 599px) 100vw, 599px" data-lazy-src="https://www.cyberciti.biz/media/new/faq/2016/08/freebsd-dd-demo.jpg" data-ll-status="loaded" />

Fig.01: dd command in action

The above command just cloned the entire hard disk, including the MBR, bootloader, all partitions, UUIDs, and data.

How to restore system (dd image)

The syntax is:
gunzip -c IMAGE.HERE-GZ | dd of=/dev/OUTPUT/DEVICE-HERE
For example:
gunzip -c centos-core-7.gz | dd of=/dev/da0

Tip #1: Not enough disk space locally? Use the remote box

You can send the image through ssh and save it on the remove box called server1.cyberciti.biz:
dd if=/dev/da0 conv=sync,noerror bs=128K | gzip -c | ssh Esta dirección de correo electrónico está siendo protegida contra los robots de spam. Necesita tener JavaScript habilitado para poder verlo. dd of=centos-core-7.gz

Tip #2: See progress while making an image with dd

You need to use GNU/BSD dd with coreutils version 8.24 as follows (pass the status=progress to the dd):
dd if=/dev/sdc1 of=/dev/sdd1 bs=128K conv=noerror,sync status=progress

Linux - repository installation

Inicio desactivadoInicio desactivadoInicio desactivadoInicio desactivadoInicio desactivado

Repository installation

# dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
# dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm



EPEL stand for Extra Packages for Enterprise Linux.
EPEL repository is a Fedora Special Interest Group that creates, maintains, and manages a high quality set of additional packages for Enterprise Linux,
including, but not limited to, Red Hat Enterprise Linux (RHEL), CentOS and Scientific Linux (SL), Oracle Enterprise Linux(OEL).

Extra Packages for Enterprise Linux (EPEL) - (See http://fedoraproject.org/wiki/EPEL) provides rebuilds of Fedora packages for EL6 and EL7. Packages should not replace base, although there have been issues around point releases in the past. You can install EPEL by running yum --enablerepo=extras install epel-release. The epel-release package is included in the CentOS Extras repository that is enabled by default. Support available on Freenode in #epel, on mailing lists, and its issue tracker. If you are willing to help test EPEL updates before they are pushed to stable, you can enable the epel-testing repository on your development/testing servers. Enabling epel-testing on production systems is not a good idea.

 


Remi repository is a yum repository maintained by a French dude – Remi Collet. This post describe the basic steps to prepare and install the additional
CentOS packages with EPEL and Remi Repository into CentOS 6.

Remi Repository - (See http://rpms.remirepo.net/) Remi Collet maintains a large collection of RPMS, including latest versions of PHP etc.
He's also got an FAQ at http://blog.remirepo.net/pages/English-FAQ .
Note that this is a collection of repos, and using the -safe series will ensure that nothing from the base CentOS Linux distro is overwritten or replaced.
However, be aware that this repo does not play nicely with other third party repos - for example,
Remi's packages contain Obsoletes: lines for packages from both IUS and Webtatic repos and thus will automatically replace them with the .remi version.
This may not be the desired behaviour and you should be careful with enabling this repo for that reason.

About 'enabled' and 'disabled' repository configuration files

Please read man 5 yum.conf, particularly the discussion of enabled=0 versus enabled=1 . A line containing one of these options is recommended for each repository in each .conf file in the  /etc/yum.repos.d/  directory. This allows the administrator to more clearly specify whether a repository is or is not used for packages. After any edits of these files, in order to clear any cached information, and to make sure the changes are immediately recognized, as root run:

# yum clean all 



After modifying the repository file with new entries, proceed and clear the DNF / YUM cache as shown.
# dnf clean all
OR
# yum clean all

To confirm that the system will get packages from the locally defined repositories, run the command:

# dnf repolist
OR
# yum repolist







A partir X automáticamente

Inicio desactivadoInicio desactivadoInicio desactivadoInicio desactivadoInicio desactivado

El documento traducido automáticamente

Entrar como administrador en el sistema linux

ir a la carpeta / etc / y editar el archivo

inittab

cambiar su valor de

id: 3: initdefault:

en

id: 5: initdefault:

Search