Перейти к содержанию

Linux commands


Keys in Linux commands

There are a some different keys types in:

  • UNIX keys - begin with "-" sign
  • BSD keys - with no any sign
  • GNU keys - with "--" sign

There are some operators in Linux commands are listed below:

  • > - stdout. Remove file content after use.

  • < - stdin

  • 2> - stderr

  • >> - append stdout file

  • &> - stdout and stderror in one file

  • | - pipe. Use to transfer stdout from one command to another.

  • $(command) assigns the result of command to some variable


Common commands in shell

Common comands in shell are listed below.

Command Desctiption
alias Create aliase for some command
bash Start new bash session.
cat Concatenate txt files.
cp Copy files.
cut Remove sections from each line on files.
command Run $com directly without alias
dmesg Print or control the kernel ring buffer.
du Estiamte file space usage.
echo Display inputted text in stdout
getent Get entries from name service switch libraries.
less Reader for files whos contains page lister, find text pattern and more
lsb_release Print distribution specific information
ldd $/bin/sh Show shared library required by program
hostname Show or set the system host name.
locate Show where specific file can be stored
ls List files in directory. Also have keys to sort results.
lsof List open files.
mkdir Create a directory.
mktemp Create a temp file in /tmp
printenv list all environment variables
sort Sort files and his content
sudoedit Execute editor which was in $EDITOR.
stat Display information about file or file system
stty Display information about current terminal
read Read data from stdin.
rm Remove file.
rmdir Remove directory
tac Concatenate txt files in reverse order.
tee Print stdput on console and write stdout to file simultaniously.
tree List contents of directories in tree format
touch Change file timestamps. Create file if it not exist.
tr Translate or delete characters
type Show information about command (location of command)
ulimit Provide control over the available resources.
uname Print system information.
updatedb Update DB for locate program
vipe Pipe to text editor (inhabit in moreutils packages)
watch Execute a given command periodically.
which Show the full path of (shell) commands.
xclip Copy from shell to clipboard (Not in coreutils)

Working with text files

Comands for work with text files in shell are listed below.

Command Desctiption
cat Concatenate file with another one.
grep Find text pattern in file(s).
head Show only few top lines of the file.
tail Show only few bottom lines of the file
wc Count number of rows, words, and other in file.

Users. Groups. Access Rules.

Comands for work with users, groups and access rules in shell are listed below.

Command Desctiption
chage Change user password expiry information.
chgrp Change group ownership.
chfn Change personal information about user (full name, phone, etc).
chown Change file owner and group.
chmod Change file mode bits.
getfacl Get file access control lists.
groupadd Create a new group.
groupmod Modify exist group.
groupdel Delete group.
gpasswd Administer groups.
groups Print the groups are user is in.
id Print user id and group IDs.
lid Display user groups or group users.
mkpasswd Encrypt the given password with given crypt and optionaly with given salt
passwd Update user authentication tokens.
setfacl Set file access control list.
su $usr Run command with substitute $usr and group ID.
sudo Execute a command as another user.
umask The user file-creation default mask.
useradd Create a new user or update default new user information.
userdel Delete user.
usermod Modify information about exist user.
visudo Allow to change /etc/sudoers file

Working with hardware without disks

Comands for working with hardware in shell are listed below.

Command Desctiption
iostat Report CPU statistics and IO statistics from devices and partitions.
lscpu Display information about cpu.
lspci List al PCI devices.
lsmod Show the status of modules in Linux kernel.
lsusb List all USB devices.
lshw List hardware.
modinfo Show information about linux kernel module.
modprobe Add and remove modules from kernel.

Working with disks and filesystems.

Comands for working with disks and filesystems in shell are listed below.

Command Desctiption
blkid Command-line utility to locate/print block device attributes.
df Report file system disk space usage.
cfdisk Display or manipulate a disk partition table.
fdisk Manipulate disk partition table.
fsck Check and repair the Linux filesystem.
lsblk Show blk hardware (disks)
lsscsi List scsi devices or hosts.
mkfs Create new file system on the partition.
mount Mount filesystem on the partition.
tune2fs Show detailed information about filesystem. Also can tune that filesystem.
resize2fs Re-write metadata of the filesystem.
umount Unmount filesystem from the partition.
xfs_repair Check and repair the xfs filesystem.
wipefs Wipe a signature from a device.

LVM

Comands for working with LVM in shell are listed below.

Command Desctiption
lvconvert Change logical volume layout.
lvcreate Create logical volume for futher work with it in LVM.
lvdisplay Show detailed information about certain LVM logical volume.
lvextend Extend exist LVM logical volume.
lvremove Remove LVM logical volume.
lvs Display exist LVM logical volumes.
pvcreate Create physical volume for futher work with it in LVM.
pvdisplay Show detailed information about certain LVM physical volume.
pvremove Remove LVM physical volume.
pvs Display exist LVM physical volumes.
vgcreate Create volume group for futher work with it in LVM.
vgremove Remove LVM volume group.
vgs Display exist volume groups.
vgdisplay Show detailed information about certain volume group.
vgextend Extend exist volume group.

Linux software based RAID.

Comands for working with linux software based RAID in shell are listed below.

Command Desctiption
mdadm Manage RAID devices.

Working with packages.

Comands for work with users, groups and access rules in shell are listed below.

Command Desctiption
apt Packet manager for Debian based system. Can search, manage and querry information about packages.
apt-cache Query information about installed as well installable packages.
apt-get Search, install, upgrade, remove packages.
apt-get install --only-upgrade <package_name> Upgrade particular package