Useful Linux commands for developers

15 April 2014

System Information

Processor Info:

 cat /proc/cpuinfo 

Memory Info:

 cat /proc/meminfo

Version of your kernel and the GCC compiler:

 cat /proc/version 

Release information

 lsb_release -a


File and display commands

Lists files with permissions, shows hidden files, displays them in a column format, and suppresses group information.

 ls -laxo

Clear screen:

 clear

Display current path:

 pwd

Remove directory with all content inside:

 rm -rf example


User access

List all users

 getent passwd

OR

 cat /etc/passwd/

List all groups

 getent group

OR

 cat /etc/group/

Switch to a different user:

 su - user2

Display current logged user:

 whoami

display members of a group:

 members mygroup

change file permission to make file executable:

 sudo chmod +x "file_name"

Open application using Super user:

 sudo open -a "app_name"

Open Graphical User Interface application using Super user:

 gksudo gedit sample.txt


Process management

List active processes:

 ps -a

discover PID of a process by name:

 pidof java

Kill process by PID:

 kill 2581

Kill process and force shutdown:

 kill -9 2581

Kill all processes with same name:

 killall java


Services

list all running services and their status:

 service --status-all

check specific service status:

 service myservice status

start service:

 service myservice start

stop service:

 service myservice stop

check if a service is currently configured to start or not on the next reboot:

 systemctl is-enabled nginx

disable service autostart:

 systemctl disable nginx

show detailed info about a service:

 systemctl show nginx


comments powered by Disqus