Basic Linux commands (CentOS 6/7)
Below we provide frequently used commands to work with Linux (CentOS) server
System Information
Show computer architecture:
Show kernel version
Show system date
Show calendar table for 2014
Files and Directories
Go to '/var/www/'
Go to the upper level directory
Go to home directory
Go to home directory of “user”
Show the contents of the current directory
Show the contents of the current directory adding characters to the names characterizing the type
Show detailed representation of files and directories in the current directory
Show hidden files and directories in the current directory
Create a directory called ‘test’
Create two directories simultaneously
Create a directory tree
Delete the file named ‘file’
Delete a directory named ‘dir’
Delete a directory named ‘dir’ and all of its contents recursively
Rename or move a file or directory
Copy file1 in file2
Create a symbolic link to a file or directory
Searching Files
Find files and directories named file1. Start searching from the root (/)
Find files and directories owned by user1. Start searching from the root (/)
Find all files and directories whose names end in ‘.log’. Start searching from ‘/var/www’
Find all files containing '.png' in the name. it is recommended to run 'updatedb' command before this.
Find all files with '.log' extension in the current directory, including subdirectories and delete them
Disk Space
Information about partitioned sections displaying total, free and used space
Show the size used by directory ‘dir1’
Users and Groups
Create user1, assign /home/user1 as its home directory, assign /bin/bash as a shell, include it in ‘admin’ group and add a comment Nome Cognome
Create user1
Delete user1 and its home directory
Create a new group named group_name
Delete group group_name
Rename group old_group_name in new_group_name
Change password
Change password of user1 (only root)
Setting/Changing File Rights
Add rights 777 (Read Write Execute) to directory1 – full rights to everybody.
Add rights to directory1, including all files and subfolders in it, rights 777 (Read Write Execute) - full rights to everybody.
Assign user1 as the owner of file1
Recursively assign user1 as the owner of directory1
Assign user 'apache' from the group 'apache' to folder 'dir', including all subfolders and files:
Find all files in the current directory, including subfolders and assign rights 664
Find all folders in the current directory, including subfolders and assign rights 775
File Archiving and Compression
Unarchive file 'file1.bz2'
Unarchive file 'file1.gz'
Archive file 'file1' to file1.gz
Archive file file1 to file1.bz2
Create an archive and zip it with gzip
Unarchive and extract
Create zip-archive
Unarchive and extract zip-archive
Upgrading Packages
Upload and install package
Update all packages installed in the system
Update package
Delete package
Show the list of all packages installed in the system
Find a package in the repository
Clean rpm-cache, deleting uploaded packages
Clean rpm-cache, deleting uploaded packages and headers