Linux Very usefull command Everyone Should know These .

How To See On Which Linux Distribution and Release Version We are working(RHEL,UBUNTU,FEDORA) .
This Command will show Our Linux Flavour Details and it's Release Version.

lsb_release -a
or
cat /etc/*verison


How to Know our Kernel Version in Linux (Redhat,Ubuntu,Fedora) .

uname -r

How to see  any file/folder size in linux .
##du(disk usage):sh(summrize,human readable):file or folder name##
Run:- du -sh filename


How to see our Linux machine running task and memory usage information .
Run:- vmstat

Allow any port in Ubuntu Firewall .
See all port Information .
Sudo netstat -ap

Open firewall menu in redhat -6 .

Run:- system-config-firewall-tui

How to enable any port in Linux redhat .

vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -p tcp --dport 443 -j ACCEPT

:wq

service iptables restart
Allow any port by command .
iptables -A INPUT -p tcp  --dport 22 -j ACCEPT

Allow any port for particular ip address or network .

/sbin/iptables -A INPUT -s 192.168.1.0/24 -m state --state NEW -p tcp --dport 80 -j ACCEPT
## save newly added firewall rules ##
/sbin/service iptables save

## verify new firewall settings 
/sbin/iptables -L INPUT -n -v

## Block access to port 80 ##
iptables -A INPUT -s 192.168.1.0/24 -p tcp --dport 80 -j DROP
/sbin/service iptables save

## verify new firewall settings 
/sbin/iptables -L INPUT -n -v

How To See which users is logged in at my linux box .

Command users it will show all users name which is logged in and command:who it will show users name with login time and source ip from where it's login .
Command: users  
Command: who

How to see which services is on/Off for all runlevel .

Command:chkconfig

If want on/off any service on particular runlevel .
like i want off smb service on Runlevl 3

chkconfig --level 3 smb off

How To Delete a user normally , we use -r for remove home directory also and can use -f for remove forcefully even user logged in .

For deltete only user

userdel username

for delte user with it's home directory

userdel -r username

How to delete a User Forcefully with home directory 

userdel -rf username

How to change root password in ubuntu while give Error

passwd: Authentication token manipulation error 
passwd: password unchanged

Reboot machine then choose advance options for Ubuntu boot 
Then choose  (recovery Mode.)
go to option : drop at root shell Prompt


mount -o remount,rw /

now change root password




No comments:

Post a Comment