All basic commands to start with Linux

1) Action on files and directories

cd [directory_name] :
To change the current directory

ls [options] [file_name] : Only, ls list the files in the current directory. If one or more names are specified, ls displays the files that belong to the named directories or whose name is one of those specified.

pwd :
Displays the absolute path of the current working directory

cp [options] file1 file2 : Copy file1 to file2. If the destination is an existing file, it will be overwritten.

touch file : Create an empty file. ">" Is an equivalent command.

mv [options] file1 file2 : Move or rename file1 to file2. If the destination is an existing file, it will be overwritten. This command also allows you to rename a file.
ln [options] file1 file2 or ln [options] directory files : Creates nicknames (links) for files, allowing access to them under different names. The first syntax allows you to create a link named file2 for file1. If file2 already exists, it is overwritten. The second syntax allows you to create links with the same name in another directory.

tar [-] key [options] [files] : Manages a set of associated files in a backup file. This is used to facilitate the transport of multiple files. The file list may contain directories; the files and directories contained in these will be archived keeping the initial tree.
find [options] [filename] : Search for files and possibly execute commands on them ; the search is recursive, it concerns the starting directory and all his descendants (sub directories and all their descendants ...).
grep [options] [filename] : Search a string of characters in files (or from the console if no file is shown); Often used as a filter with other commands with the symbol "| ".
locate : Give the file path. Do regularly updatedb to update the database of installed files.

cat [options] [files] : Reads one or more files and displays them in the terminal. You can use the operator ">"
to concatenate multiple files into a new file. In the same way the operator ">>" allows you to add files at
the end of an existing file.

more file : Displays the file in a terminal page by page. Some keys allow navigate and change the display.

less file : View the contents of a file directly in the terminal.
chown [username] file : Change the owner of a file or directory. Only the owner of the file (or root) can do this manipulation.

chgrp [group_name] file : Change the group of a file or directory. Only the owner of the file (or root) can do this manipulation.

chmod [options] file mode : Change the access rights (in a certain mode) of one or more files. Only the owner of the files or a user with special rights can change the access mode. The access mode format consists of three parts: level(s) Operation Right(s). If no level is specified, the change is made at all levels. Only one operation is possible at a time.

2) Device Management
mount [options] [device_name] [device_path] : Mount a file system.

umount [options] [device_name] : Unmount a file system.

eject [device_name] : Eject an optical media from a drive.

lspci [option] : List all PCI devices.

lsusb [option] : List all USB devices.
fsck [options] [names] : Checks and repairs a Linux file system.

ntfsfix [options] device : Fix NTFS errors.

dosfsck [options] device : Checks and repairs an MS-DOS file system.

mkfs [options] partition : Format a partition with a given file system.

dumpe2fs [options] partition : Displays the health information of partitions formatted in ext2 / ext3 or ext4.
3) System Process Management
top : Displays in a terminal in real time, processes active. to leave do "Ctrl + c".

ps [options] [PIDs] : Displays the list of active processes.

kill [options] IDs : Ends one or more processes referenced by their IDs.
4) System Information
fdisk [options] [DiskPath] : Utility to read or modify the disk allocation table present on the system.

df [options] : Displays the amount of disk space used by the file systems.

du [options] : Displays the space used by directory.

free [options] [names] : Displays the available & used memory of the system.

uptime : Gives a line of information about the machine: the time, how long the machine has been running, how many users are logged in and the computing load averaged over 1.5 and 15 minutes.
5) User and group management
useradd [options] user : Adds a local user.

adduser user : Adds a local user. This command requests additional information (password, full name, office number, business phone, personal phone, other).

usermod [options] user : Changes the settings of a user account.

userdel [options] user : Deletes a user account and associated files.
groupadd [options] group : Adds a group to the system.

groupdel group : Deletes a group on the system.

groups username : Shows the groups to which belongs a user.

id username : Displays the user and group information for a specified user, or if no user is specified, it displays information about the current user.
6) The network
ifconfig [interface] [options] : Allows you to view and temporarily change the config of the network interfaces.

ifdown [options] [interface] : Disables network interfaces.

ifup [options] [interface] : Enables to activate the network interfaces.

route [options] : Displays / manipulates the routing table.
7) Software installation
dpkg [options] software_name : Utility to manage software without dependencies.

dpkg-reconfigure software_name : Utility to reset default binaries.

apt-get [options] software_name : Utility to manage software (Debian / Ubuntu).

aptitude [options] software_name : Utility to manage software (Debian).

apt-cache [option] software_name : Utility giving a list of packages whose name contains software_name.

yum [options] software_name : Utility to manage software (CentOS / Redhat).

Cambodia Computer Advertisement
Copyright 2017 -