Linux General

Command

General Command


Linux Status


Shell


Check Current User

whoami

Show user UID, GID, Group

id user_name

user_name is user name

Add PATH

In this example, $HOME/bin is added

export PATH=$PATH:$HOME/bin

To add it to .bash_rc is a good idea

Look for command path

whereis psql

This example is find PostgreSQL command(psql)

Date tech

1 day ago

`date -d "1 day ago" +\%Y\%m\%d`

Create zip with directory

zip -r xx.zip xx/

CPU

CPU info is under /proc/cpu

cat /proc/cpu

Check Memory

Memory info is under /proc/meminfo

cat /proc/meminfo

Shell variable and Environment variable

Environment variable Apply all shell
Shell variable Variable for just shell

Show all environment variable

env
printenv

Show shell var with environment var

set

Shell Script Env

Add #!/bin/bash to top of script.
This script file was handled as script file.

Shell Setting File

Files

File Description
/etc/profile When log on, For all users
~/.bash_profile When log on
~/.bash_login If ~/.bash_profile is missing, this runs when log on
~/.profile If ~/.bash_profile and ~/.bash_login are missing
~/.bashrc When bash starts
~/.bash_logout When log out

For

File For
/etc/profile For all user common setting
~/.bashrc For personal setting