Linux Commands

File System
df -h
  – Show file system usage

du -hs
  – Show current folder disc space usage

du -a -h --max-depth=1 | sort -rh
  – List 1st-level subfolders and files with size

fdisk -l | grep Disk
  – Display total harddisk size

ls -lZ
  – Display the security context associated with files or directories

ls | wc -l
  – List number of files and directories for the current folder

dd if=/dev/zero of=<filename> bs=1024k count=10
  – Create a 10MB file (file size = bs x count)
 

User and Group
grep ^groupname /etc/group
  – List all user of a group

groupadd groupname
  – Create new group

groups
  – List all groups of the current user

htpasswd -c passwdfile username
  – Create password file with username or truncate and rewritten if exists

passwd username
  – Change the password of an exiting user

useradd username
  – Create user

useradd -m -s /bin/bash username
  – Create user with default home folder and bash as default shell

usermod -a -G groupname username
  – Add existing user to an existing group
 

System Inforamtion
uname -mrs
  – Linux kernal version and microprocessor architecture

dmesg
  – Display the boot msg

ps aux OR ps -ef
  – Show running process

netstat -r
  – Show the IP routing table including gateway address

netstat -tuna
  – List the listening port

netstat -tulpn | grep :<port>
  – Find the process which occupies a specific port

grep -i –color “model name” /proc/cpuinfo
  – Find the number of CPU cores
 

Hard Disk & Partition
e2fsck
  – Checkdisk

fdisk
  – Fixdisk

mke2fs
  – Format hard disk

tune2fs
  – Edit the parameters of the partition
 

Cron Job
crontab -e
  – Edit cron jobs

crontab -l
  – List all cron jobs

select-editor
  – Select text editor for crontab

About these ads

One thought on “Linux Commands”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

About these ads

Dream BIG and go for it =)

%d bloggers like this: