You are here: Home / What do you need? / Help and documentation / Unix tricks and information / Useful Linux commands

Useful Linux commands

by Darrell Kingsley last modified Mar 13, 2014 03:19 PM
Some handy Linux commands that we always forget...
netstat -tulpen

lists all active ports and listening services

nmap -sT -p 1-9000

- same as above but more readable - list services listening to ports 1-9000 on local machine (except this doesn't seem to exist on BB1)

xinetd - red hats imlpentation of inetd (wake-up process) in /etc

To restart a xinetd process use the following (e.g. sshd)

service sshd restart


chkconfig --list

lists xinetd controlled ports

To check the pid of a service (e.g. sshd)

cat /var/run/


Another way to kill a process "seems" to be (check before using). There are all these .pid files in /var/run which you can cat and get the pid. These are likely to be set up when a process starts to store the pid. Investigate further.

	rm -f /var/run/
	/etc/rc.d/init.d/sshd start

 /etc/services all ports and mapped services


Make aliases

Edit the ~/.bashrc file adding e.g. alias trousers="cd /opt/trousers"

On Mac it is ~/.bash_login

Alternatively, in order for it to be added for all users, add your alias or other change to /etc/bashrc

Users and groups

To add user to /etc/sudoers file use command visudo (from root)

Add a group

groupadd plone

Add a new user

useradd plone -g plone -d /home/plone -p password

Basic OS info

Here's how to get that easy-to-forget info about your Linux OS.

Centos/Redhat release:
cat /etc/redhat-release

More info about the OS:

uname -a