Skip to content

System administration 1: Useful Commands and Locations on Windows and Unix/Linux

This post lists common commands used in Windows and Linux/Unix system administration, server support, and troubleshooting.

The first command indicates the command name (searchable with a man page). The parens indicate useful extensions

Command Usage/Function
ls (-al) List files and directories
find (./ -name or expression ‘in quotes’) -print Find files given filename and other parameters.Some usage patterns are below.-exec is powerful since it defines what to do with the file(s) found by the find command. For example, you can use grep to look for information inside those files (see below).
find / -type f -exec grep -l “stringhere” {} ; Find files containing a string called “stringhere”
find / -type f -print -exec grep -l “stringhere” {} ; >Find files containing a string called “stringhere” and output the lines from those files that contain that string. -print will show which files were found.
find . -name ‘*s’ -print To see which files within the current directory and its subdirectories that end in s
grep Display files and extract information containing word / pattern after the command
egrep Extract line containing word / pattern after the command
pwd Print (output to console) current working directory
less, more Console content control/reader
locate
Cp
mv
Rm (-Rf) Remove (with recursive and forced)

/ampersand (&)/ - Executed after a UNIX command makes the command run while providing the command prompt back. Using & allows you to continue to type more UNIX commands. Common use of the ampersand ( & ) is at the end of commands that open their own windows like a web browser or an editor.. The amperand (&) means something different when used immediately after a greater than (>) for output redirection or after the pipe symbol ( | ) for passing output to other commands.

Command Usage/Function
cat
man Manuals (help pages) for system commands.
ln –s Create symbolic links between files
touch
ftp File transfer protocol program
ping
finger
telnet
ssh Secure Shell
bash Bash shell (running activates bash shell on console if it is available).
Rm (-Rf) Remove (with recursive and forced)
nslookup OR dig OR host Domain name service lookupdig -x <ip> or nslookup <ip> does reverse lookup
whois Query
traceroute Trace network route
lynx Text based HTML browser
mount, unmount Mount or unmounts file systems
date Date/time on system
runmqsc (WebSphere Messaging Queue MQ) ex. runmqsc <queue> DISPLAY CHSTATUS(*) - display all channels info DISPLAY CHSTATUS(‘<queue>’) STOP CHANNEL(‘<queue>’) RESET CHANNEL(‘<queue>’) START CHANNEL(‘<queue>’) DISPLAY CHANNEL(‘<queue>’)
wget GNU tool to retrieve web or file content.
Example of using wget to create of backup of a website (web archive) stored on your local computer. See the wget manual for more options.*Get/backup website content for offline viewing: [darkbox]*wget -c -m -k -K -E -P/tmp http://url_of_the_website[/darkbox] Get/backup website content for offline viewing. Limit rate to reduce load on the target website and ignore robots file. Ignoring the robots file is helping for backuping up everything under a website and for WordPress blogs. [darkbox]*wget -c -m -k -K -E -P/tmp –limit-rate=300k -e robots=off http://url_of_the_website*[/darkbox] Here is what each option means:
- wget > Download web content
- -c continue from partially downloaded files, useful for finishing a partial wget in the past
- -m or –mirror > recursively with time-stamping (), while
- -k -K > converting links for local viewing
- -E or –html-extension > and add .html extension for html files if not present.
- -P or –directory-prefix=… > Download the web content to the directory indicated; in this case /tmp.
- http://… > Location where to start the web backup / archival
- —-limit-rate (e.g. –limit-rate=300k —-wait=2> To limit your download rate and prevent overloading or taxing the performance of the web server
Command Usage/Function
prstat: report active process statisticssar: System activity reportermpstat : Report per-processor or per-processor-set statistics Check CPU utilization, per CPU statistics. (e.g. sar 1, sar -u 10 60, mpstat 10 60)(e.g. Stats by zone: prstat -Z, Stats by Projects/users prstat -J)
useradd (Solaris) Create a user Example: useradd -d /export/home/smithjo -m -k -s /bin/bash -c “John Smith” -g100 smithjo
userdel (Solaris) Remove a user. Example: userdel -r smithjo The -r option removes the users home directory and login information
groupadd (Solaris) Modify a user’s information like group
usermod (Solaris) Modify a user’s information like group
rpm (Redhat based systems) Package manager
ifconfig (-a) Display IP address information including loopback and inet interfaces, sometimes in /usr/sbin
hostname (-f) Obtain hostname information of server
domainname Display a servers domain name
pkgadd (Solaris), yum (Fedora, RPM)package-cleanup Package manager tools (e.g. yum install <program name>
chkconfig
chownchmodchgrp File ownership and rights management. E.g. chown <new owner> <filename>chmod 664 <filename> for rw-rw-r
*File compressions and ExtractionCompress*gzip -c file1 file2 > foo.gztar cf – targetfile_ordirectory gzip -c > target.tgzg*/_tar -cvzf target output.tgz_/Uncompress*gzip -dc outputfile.tar.gz
sendmail Mailer
mail Email management
head
tail (-f) See near end of file or stream file with -f
passwd User password management
su Assume root user or user specified after command. Will prompt for password.
sudo Assume root user only for command following sudo. Will prompt for password.
last
who
df (-akh) Reports on disk space on mounted and mounted file systems
md5 Checksum command
cron Scheduler
uname (-a) System/machine information
ps (-ef) (-Al) List (all) processes and their details
xinetd
kill (-HUP) Send signals to process. E.g. kill -9 <pid> kills a process with pid specified
shutdown (now) (-r) Shutdown operating system e.g. -r restart afterwards “now” shuts the system down right away without a time delay
netstat (-an) Network information for system, port listeners and addresses. E.g. netstat –rn* *to view existing kernel IP routing table
Command Usage/Function
gcc (or cc) C compiles
pico, nano File editors
make Builder program

*Logs, spoools, and file resources (mail, logs, temp, etc.):* /var

*Configuration Files:* /etc, /etc/rc.init (startup scripts). /etc/sendmail.cf

*Unix “blackhole”:* /dev/null

*Core Command locations if not in path:* /usr/(s)bin, /usr/local/(s)bin, usr/sfw/bin | Solaris: /usr/openwin

*Devices (I/O):* /dev

*Mounted Systems:* /mnt, /media

*Code Libraries/Modules:* /usr/lib, /usr/local/lib

*Stored source:* /usr/src

​**Services: **/etc/services - example of entries in services file (ports and protocols associated with the ports.

netstat 15/tcp

ftp 21/tcp # File Transfer

ssh 22/tcp # Secure Shell

telnet 23/tcp

User settings ~/.<user setting folder>

e.g. ~/.kde/share/apps stores KDE desktop settings and configurations.

Checking serviers and ports in netstat

less /etc/services | grep <service name>

netstat -a | grep <service name>| grep <keyword, e.g. LISTEN>

  1. Check Total physical memory:

    ​# prtdiag -v | grep Memory # prtconf | grep Memory

  2. Check Free physical Memory:

    ​# top (if available) # sar -r 5 10 Free Memory = freemen*8 (pagesize=8k) ​# vmstat 5 10 Free Memory = free

  3. For swap:

    ​# swap -s # swap –l

Command Usage/Function
certmgr.msc Certificates
ciadv.msc Indexing Service
comexp.msc Component Services
compmgmt.msc Computer Management, central administration panel for Windows. Can also be used to access IIS administration console.
control mouse Open control panel for mouse
defrag, dfrg.msc Disk Defragmenter
devmgmt.msc Device Manager
diskmgmt.msc Disk Management
eventvwr.msc Event Viewer
fsmgmt.msc Shared Folders
gpedit.msc Group Policy
lusrmgr.msc Local Users and Groups
msconfig Startup files and processes configuration
ntmsmgr.msc Removable Storage
ntmsoprq.msc Removable Storage Operator Requests
perfmon.msc Performance monitor
regedit Registry editor
rsop.msc Resultant Set of Policy
sc query Find function. E.g. Find a Windows services called “WSearch”sc query
secpol.msc Local Security Settings
services.msc Services and Process manager
wab Windows address book
wmimgmt.msc Windows Management Infrastructure (WMI)
Section titled “Remote Desktop Management related commands”

ERROR The terminal server has exceeded the maximum number of allowed connections

Section titled “ERROR The terminal server has exceeded the maximum number of allowed connections”

If you encounter this error, you can either reboot the terminal server you are trying to remote desktop to or log into the machine as an administrator.

To log in as the administrator:

mstsc /v:<ip address e.g. 192.168.2.32) /console

By using /console at the end of the command you will be logging in as if you were at the server. Alternatively, if you are using Windows Server 2003, run this comment instead (replace /console with /admin)

mstsc /v:<ip address e.g. 192.168.2.32) /admin

If you can telnet or ssh to the server you can use the following command. This command will kill all active RDP sessions to free one so you can connect.

tsdiscon /1

tsdiscon /2

tsdiscon /3

tsdiscon /4

When you execute the commands above, log in as an administrator on the machine. That log in allow you to use the console on the server.

  1. Remove any disconnected users via the Terminal Services Manager

    Start > All Programs > Administrative Tools > *Terminal Services Manager*

    Click on the name of your server and the right side should show a list of users. If the users are disconnected, reset the users to free up the two normal remote desktop connections. Right clicking the disconnected user and selecting “Reset.”

    It is good practices to only use the console to disconnect inactive sessions and not for anything else. Make sure you disconnect inactive user sessions first with the instructions above, otherwise if you get disconnected again you will have to physically access the server.

    Remote Desktop sessions should always be closed using the Windows <<Log Off>> function rather than disconnecting by closing the window as using the X to close will disconnect from the session but leave it active.

Despite carefully following installation and configuration procedures for various programs, they still tend not be smooth.