November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Rebooting linux without reboot command

Rebooting linux without reboot command

Just a sample of how you can reboot or shutdown linux without issuing reboot command, so called hard reboot. That means that system will just make a reset as if you pressed a reset button, without running any shutdown scripts, etc. A kind of dangerous staff, but can be helpful […]

SUDO on Linux

SUDO on Linux

cat /etc/passwd

test:x:500:500:test:/home/test:/bin/bash

[root@localhost ~]# cp /etc/sudoers [root@localhost ~]# cp /etc/sudoers /etc/sudoers.org

1) Full Permission to User # User privilege specification test ALL=(ALL) ALL

Let restart apache with out sudo

[test@localhost ~]$ /etc/init.d/httpd restart rm: cannot remove `/var/run/httpd/httpd.pid’: Permission denied

test@localhost ~]$ sudo /etc/init.d/httpd restart [sudo] password for test: […]

Netstat

Netstat

netstat -antpuleo

Will display the Timer running on the service

Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name Timer tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 0 9169 1246/rpcbind off (0.00/0/0) tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 0 22083 14524/sshd off (0.00/0/0) tcp 0 0 0.0.0.0:36998 0.0.0.0:* LISTEN […]

Eating your memory? Let is find Out

Works on CENTOS AND FEDORA Prints the top 10 memory consuming processes

TR=`free|grep Mem:|awk ‘{print $2}’`;ps axo rss,comm,pid|awk -v tr=$TR ‘{proc_list[$2]+=$1;} END {for (proc in proc_list) {proc_pct=(proc_list[proc]/tr)*100; printf(“%d\t%-16s\t%0.2f%\n”,proc_list[proc],proc,proc_pct);}}’|sort -n |tail -n 10

sgid

SGID attribute

Setting the SGID attribute on a directory : chmod g+s

If the SGID (Set Group Identification) attribute is set on a directory, files created in that directory inherit its group ownership.

If the SGID is not set the file’s group ownership corresponds to the user’s default group.

In order to set the SGID […]

Link commands

delete symbolic link

When using the rm or unlink command to remove a symbolic link to a directory, make sure you don’t end the target with a ‘/’ character because it will create an error. Example:

$ mkdir dirtest $ ln -s dirtest lntest $ rm lntest/ rm cannot remove directory ‘lntest/’ : Is a […]

File /Folder Permissions

File /Folder Permissions

These are the numeric values and its related permissions in a linux system.

4000 – Setuid on execution 2000 – setgid on execution 1000 – set sticky bit 0400 – read by owner 0200 – write by owner 0100 – execute by owner 0040 – read by group 0020 – wrrite by […]

Kill processes for user

Kill processes for user

To easily kill all processes running under a user

ps -u USER | awk ‘{print $1}’ | xargs kill -9

or

pkill -u USER

replacing USER with the username.

To kill all specific processes such as php running under a user run,

ps -u USER | grep PROCESS |awk ‘{print $1}’ […]

Hide Commands in Shell

Hide Commands in Shell

To hide the commands you are entering in shell, use “stty” command 🙂

#stty -echo

Now, all commands that you type are invisible. To disable this mode, issue the following command at the shell prompt:

#stty echo

Commands to Monitor Servers (CENTOS AND REDHAT)

Commands to Monitor Servers (CENTOS AND REDHAT)

These commands are mainly for rpm based linux servers like CentOS etc..

May be some commands works in ubuntu servers etc…

Command to find out total established connections, closing connection, TIME_WAIT and much more.

netstat -nat | awk ‘{print $6}’ | sort | uniq -c […]