Windows (//z 2012-2-21 13:42:23 PM IS2120@CSDN)
ipconfig | Show my IP address |
ipconfig \all | Show my host name, IP addr, MAC addr, subnet mask, DNS servers, etc. |
netstat | List all TCP connections |
netstat -a | List all active ports |
nslookup host | Get IP addr for host |
ping host | See if a host is accessible |
Unix/Linux
System related
|
|
uptime | Show how long the system has been up |
uname -a | Show the OS name and version |
hostname | Shows the machine's name |
ps -f -u username | Lists all the processes I'm running |
echo $0 | Shows what shell I'm using |
echo $path | Shows my path (or any environment variable) |
Network related
|
|
netstat | List all TCP connections |
netstat -a | List all active ports |
nslookup host | Get IP addr for host |
ping host | See if a host is accessible |
telnet domain_name 80 | Use telnet to make an HTTP request Example to view http://www.harding.edu/comp/: telnet www.harding.edu 80 GET /comp/ HTTP/1.1 Host: www.harding.edu |
Disk space (//z 2012-2-21 13:42:23 PM IS2120@CSDN)
|
|
df | Shows the amount of disk space in use |
df /node_or_dirname | Shows detailed information about the file system node or dir name |
du | Shows the amount of disk space used in every dir from current location |
du -ks ~fmccown | Shows the amount of disk space user fmccown is using (in KB) |
cd;du -k | sort -nr | more | Shows the disk space used (in KB) for every directory in sorted order |
File processing
|
|
file myfile | Short summary of what type of file myfile is |
cat file1 file2 > file3 | Concatenates file1 and file2 and stores the result in file3 |
sort file.txt | Sorts a file |
uniq file.txt | Remove duplicate lines from a sorted file |
wc file.txt | Counts number of lines, words, and characters in a file |
grep search_str file.txt | Search for a search_str in a files |
tail -f file.txt | List the contents of a file as it is being added to |
tail -n 100 file.txt | List the last 100 lines of a file |
find . -name "*html" | Find all files named *html starting in the current dir |
find . -exec grep "hello" '{}' \; -print | Run grep on all files starting in the current dir |
cat myfile | hexdump -C | Produce a hexdump of myfile |
File compression
|
|
tar cfz my.tar.gz *.html | Creates a gzipped tar file for all .html files |
tar -tzf my.tar.gz | Lists the contents of my.tar.gz |
tar xvfz my.tar.gz | Uncompresses and untars my.tar.gz |
gzip myfile.txt | Compresses myfile.txt creating myfile.txt.gz |
gzip -d myfile.txt.gz | Uncompresses myfile.txt.gz creating myfile.txt |
bzip2 myfile.txt | Compresses myfile.txt creating myfile.txt.bz2 (Use -k to keep myfile.txt) |
bzip2 -d myfile.txt.bz2 | Uncompresses myfile.txt.bz2 creating myfile.txt |
I/O redirection
|
|
cmd > log.txt | Redirect cmd output (stdout) to log.txt |
cmd >> log.txt | Append stdout to log.txt |
cmd 1> out_log.txt 2> err_log.txt | Send stdout to out_log.txt and stderr to err_log.txt |
cmd &> log.txt | Redirect stdout and stderr to log.txt. Note: use >& for C shell. |
Running processes
|
|
./cmd & | Run process in the background |
nohup ./cmd & | Run process in the background, and don't terminate when shell is terminated |