Basic Linux Commands
Basic Linux Commands
System Information
arch
uname -r
date
cal 2014
Go to '/var/www/'
cd /var/www
cd ..
Go to home directory
cd ~
cd ~user
ls
Show the contents of the current directory adding characters to the names characterizing the type
ls -F
Show detailed representation of files and directories in the current directory
ls -l
ls -a
mkdir test
mkdir -p /var/www/test/dir
rm -f file
rmdir dir
rm -rf dir
mv dir1 new_dir
cp file1 file2
ln -s file1 file2
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.
locate "*.png"
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
df -h
du -sh dir1
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
useradd user1
groupadd group_name
groupdel group_name
Change password
passwd
passwd user1
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 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 . -type f -printf "\"%p\" " | xargs chmod 664
Find all folders in the current directory, including subfolders and assign rights 775
bunzip2 file1.bz2
gunzip file1.gz
gzip file1
bzip2 file1
Create zip-archive
unzip file1.zip
Upgrading Packages
yum update
Update package
Delete package
yum list
Help Commands
File Operations
Process Management
Networking
Directory Operations