List of Linux Commands
List of Linux Commands
Basic Commands
1 ls - list files
2 ls -a list hidden files
3 cp - copy a file (source destination)
4 mv - move a file (source destination)
5 mv - command is used to rename a file for ex : mv httpd.conf httpd.conf-bak
6 cp - to copy a folder : cp -var (source destination)
7 uname -a Show system and kernel
8 date - show system date
9 bc - basic calculator
10 whoami - shows your username
11 id - shows the id for a user
12 man - show manual for command
13 pwd - show current working directory
14 mkdir - create a directory
15 mkdir -p create a directory for ex : mkdir -p linux/ubuntu
16 cd - change a directory
17 cd .. Go to previous directory
18 top - Show real time processes
19 rm basic - to delete a file
20 rm -I basic - to delete a file by asking the confirmation
21 rm -rf - deletes the file without confirmation and recursively
22 locate httpd.conf - locate a file
23 find / -name httpd.conf - locate a file
24 grep -ril - to search for a line in a file
25 netstat -pant - list of ports listening to servers
26 netstat pant | grep 80 (to find http port is listening in the server)
27 tailf - to see the last lines in a file : for ex : tailf /var/log/httpd/error.log
28 head- to see the last lines in a file : for ex : tailf /var/log/httpd/error.log
29 more ex : cat /etc/httpd/conf/httpd.conf | more
30 less ex : cat /etc/httpd/conf/httpd.conf | less
31 ls -lh - detailed list with human readable format
32 df -h - to view the disk space
33 du -sch * - to view the folders or files in human readable format
34 file filename - to view the file format
35 stat - file or folder name to view the file permission in human readable formar like 777 or 755 or 644
36 crontab -l - to list the cronjobs
37 crontab -e - to edit or add the cron jobs
38 yum install httpd - to install a software via yum
39 yum search httpd - to search for a software via yum
40 yum remove httpd - to remove a software
41 hostname - to view the hostname
42 service httpd start,stop,restart
43 /etc/init.d/httpd start,stop,restart
44 ifconfig - to find the ipaddress
45 ip a - to know the ip address
46 cat /etc/issue - to know the OS details
47 arch - to know the system architecture 86 or 64 bit
48 getenforce - to know the selinux status
49 passwd user - to reset the password for a user
50 cat /proc/cpuinfo- to know the CPU details
hostnamectl
File Permission
4 read (r)
2 write (w)
1 execute (x)
To Change Permission for a file or folder
chmod 777 file or folder name
chmod -R 777 file or folder name - to change the permission recursively to folders and sub-folders
chown root.root file or folder name
chown -R root.root file or folder name- to change the user group recursively to folders and sub-folders
Mysql Commands
To Backup Database
mysqldump -u root -p databasename > demo.sql --verbose
To Restore Database
mysql -u root -p databasename < demo.sql --verbose
To login to mysql shell
mysql -u root -p
To View Database
show databases;
To Create Database
create database database name;
To Drop Database
drop database database name;
To Create User
Create user username;
To Drop User
drop user username;
To Grant full priviliges for a user
grant all privileges on alpha.* to 'omega'@'localhost' identified by 'gear';
alpha - Database Name omega - username gear - password
Vim Basic Commands
vim filename - create a file
shift+G - to goto last line in a file
shift+1 - to goto first line in a file
dd - to delete a single line in a file
dG - to delete all lines in a file
insert - to add a text in a file
:q - to quit vim
:wq - to save a quit
:q! - force quit
:wq! - To save a force quit
:$ - goto last line
Memory Process
echo "USER RSS PROCS" ; echo "-------------------- -------- -----" ; ps hax -o rss,user | awk '{rss[$2]+=$1;procs[$2]+=1;}END{for(user in rss) printf "%-20s %8.0f %5.0f\n", user, rss[user]/1024, procs[user];}' | sort -rnk2
Basic Commands
1 ls - list files
2 ls -a list hidden files
3 cp - copy a file (source destination)
4 mv - move a file (source destination)
5 mv - command is used to rename a file for ex : mv httpd.conf httpd.conf-bak
6 cp - to copy a folder : cp -var (source destination)
7 uname -a Show system and kernel
8 date - show system date
9 bc - basic calculator
10 whoami - shows your username
11 id - shows the id for a user
12 man - show manual for command
13 pwd - show current working directory
14 mkdir - create a directory
15 mkdir -p create a directory for ex : mkdir -p linux/ubuntu
16 cd - change a directory
17 cd .. Go to previous directory
18 top - Show real time processes
19 rm basic - to delete a file
20 rm -I basic - to delete a file by asking the confirmation
21 rm -rf - deletes the file without confirmation and recursively
22 locate httpd.conf - locate a file
23 find / -name httpd.conf - locate a file
24 grep -ril - to search for a line in a file
25 netstat -pant - list of ports listening to servers
26 netstat pant | grep 80 (to find http port is listening in the server)
27 tailf - to see the last lines in a file : for ex : tailf /var/log/httpd/error.log
28 head- to see the last lines in a file : for ex : tailf /var/log/httpd/error.log
29 more ex : cat /etc/httpd/conf/httpd.conf | more
30 less ex : cat /etc/httpd/conf/httpd.conf | less
31 ls -lh - detailed list with human readable format
32 df -h - to view the disk space
33 du -sch * - to view the folders or files in human readable format
34 file filename - to view the file format
35 stat - file or folder name to view the file permission in human readable formar like 777 or 755 or 644
36 crontab -l - to list the cronjobs
37 crontab -e - to edit or add the cron jobs
38 yum install httpd - to install a software via yum
39 yum search httpd - to search for a software via yum
40 yum remove httpd - to remove a software
41 hostname - to view the hostname
42 service httpd start,stop,restart
43 /etc/init.d/httpd start,stop,restart
44 ifconfig - to find the ipaddress
45 ip a - to know the ip address
46 cat /etc/issue - to know the OS details
47 arch - to know the system architecture 86 or 64 bit
48 getenforce - to know the selinux status
49 passwd user - to reset the password for a user
50 cat /proc/cpuinfo- to know the CPU details
hostnamectl
File Permission
4 read (r)
2 write (w)
1 execute (x)
To Change Permission for a file or folder
chmod 777 file or folder name
chmod -R 777 file or folder name - to change the permission recursively to folders and sub-folders
chown root.root file or folder name
chown -R root.root file or folder name- to change the user group recursively to folders and sub-folders
Mysql Commands
To Backup Database
mysqldump -u root -p databasename > demo.sql --verbose
To Restore Database
mysql -u root -p databasename < demo.sql --verbose
To login to mysql shell
mysql -u root -p
To View Database
show databases;
To Create Database
create database database name;
To Drop Database
drop database database name;
To Create User
Create user username;
To Drop User
drop user username;
To Grant full priviliges for a user
grant all privileges on alpha.* to 'omega'@'localhost' identified by 'gear';
alpha - Database Name omega - username gear - password
Vim Basic Commands
vim filename - create a file
shift+G - to goto last line in a file
shift+1 - to goto first line in a file
dd - to delete a single line in a file
dG - to delete all lines in a file
insert - to add a text in a file
:q - to quit vim
:wq - to save a quit
:q! - force quit
:wq! - To save a force quit
:$ - goto last line
Memory Process
ps hax -o rss,user | awk '{a[$2]+=$1;}END{for(i in a)print i" "int(a[i]/1024+0.5);}' | sort -rnk2
Comments
Post a Comment