Disable copy text

Monday 7 January 2013

 


Linux Some Basic Commands

Process

ps -auwx - Report a snapshot of the current processes

pstree - Display a tree of processes

pmap - Display/examine memory map and libraries

pidof processname - Find the process ID of a running program

pgrep processname - Look up or signal processes based on name and other attributes

ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10

Performance

iostat - Report Central Processing Unit (CPU) statistics and input/output statistics for devices and partitions

vmstat - Report virtual memory statistics

mpstat - Report processors related statistics

netstat - Print network connections, routing tables, interface statistics, masquerade connections and multicast memberships

free - Display amount of free and used memory in the system

top - provides a dynamic real-time view of a running system

slabtop - display kernel slab cache information in real time

sar - Collect, report, or save system activity information

General Info

uname - print system information

uptime - Tell how long the system has been running

cat /proc/meminfo - Show memory size and usage

runlevel - find the current and previous system runlevel

chkconfig - updates and queries runlevel information for system services

ntsysv - simple interface for configuring runlevels

init, telinit - process control initialization

w - Displays currently logged in users and processes they are running

who - show who is logged on

whoami - Displays user id

chsh - change your login shell

login - sign on

/etc/shells is a text file which contains the full pathnames of valid login shells

set - Display all environment variables in your current environment

id - Display user and all group ids

last, lastb - Listing of most recent logins by users.command

history - Shell command to display previously entered commands

sysreport - collect some detailed information about the hardware which will be used to diagnose problems with the system

hostname - show or set the systemâs host name

domainname - show or set the systemâs NIS/YP domain name

dnsdomainname - show the systemâs DNS domain name

nisdomainname - show or set systemâs NIS/YP domain name

ypdomainname - show or set the systemâs NIS/YP domain name

Kernel

ipcs - List share queues, Shared memory, List Semaphores.

cat /proc/modules List all currently loaded kernel modules.

lsmod - List loaded modules

insmod - Inserts a module into the active kernel

rmmod - Remove a loaded module. Just specify the module name. No ".o" or path necessary.

modprobe - High level handling of loadable modules. Loads module and dependencies.

depmod - Creates dependencies file for a module (used by modprobe)

modinfo - Display information about a kernel module

sysctl - configure kernel parameters at runtime

Network

ifconfig - configure a network interface

setting in /etc/sysconfig/network. Command will change entry in /etc/hosts

mii-tool - view, manipulate media-independent interface status

ethtool - Display or change ethernet card settings

route - show / manipulate the IP routing table

Filesystem

proc - process information pseudo-filesystem

fstab - static information about the filesystems

fsck - check and repair a Linux file system

df - report filesystem disk space usage

du - estimate file space usage

mount - mount a file system

umount - unmount file systems

fdisk - Partition table manipulator for Linux

lsof filesystem - list open files

fuser - identify processes using files or sockets

e2label - Change the label on an ext2/ext3 filesystem

mkfs -t ext2 /dev/ram - build a Linux file system

mke2fs - create an ext2/ext3 filesystem

e2fsck - check a Linux ext2/ext3 file system

tune2fs - adjust tunable filesystem parameters on ext2/ext3 filesystems

dumpe2fs - dump ext2/ext3 filesystem information

partprobe - inform the OS of partition table changes

mkswap - set up a Linux swap area

swapon, swapoff - enable/disable devices and files for paging and swapping

NFS

exportfs - maintain list of NFS exported file systems

showmount - show mount information for an NFS server

nfsstat - print NFS statistics

Files

ls - List directory contents. List file information

fuser - Identify processes using files or sockets

file - Identify file type.

File permission

chmod - Change a file's mode or permissions

umask - Set default file permissions

chgrp - Change a file's group

chown - Change a file's owner

chroot - run command or interactive shell with special root directory

ACL

setfacl - set file access control lists

chacl - change the access control list of a file or directory

getfacl - get file access control lists

User

useradd - Create a new user or update default new user information

usermod - Modify a user account

userdel - Delete a user account and related files

passwd - update a userâs authentication tokens(s)

finger - user information lookup program

chfn - change your finger information

chage - change user password expiry information

users - Show all users logged in.

Group

groupadd - Create a new group

groupmod - Modify a group

groupdel - Delete a group

newgrp - log in to a new group

gpasswd - administer the /etc/group file

grpck - verify integrity of group files

groups - Display groups you are part of

Hardware Info

/usr/bin/lsdev - List devices and info on system hardware. Also IRQ's.(RPM package procinfo)

/sbin/lspci - List all PCI devices (result of probe) Also lspci -vvx and cat /proc/pci

cat /proc/interrupts - List IRQ's used by system and the device using the interrupt.

cat /proc/ioports - List I/O ports used by system.

cat /proc/dma - List DMA channels and device used by system.

cat /proc/cpuinfo - List info about CPU.

hdparm -I /dev/hda - get Harddisk info

Debugging

kill - terminate a process

killall - kill processes by name

pkill - will send the specified signal (by default SIGTERM) to each process instead of listing them on stdout

nice - run a program with modified scheduling priority

renice - alter priority of running processes

ulimit

Log files

closelog, openlog, setlogmask, syslog - control system log

/var/log/messages - system messages

/secure - Logging by PAM of network access attempts

/dmesg - Log of system boot. Also see command dmesg

/boot.log - Log of system init process

/xferlog.1 - File transfer log

/lastlog - Requires the use of the lastlog command to examine contents

/maillog - log from sendmail daemon

No comments:

Post a Comment