| ![]() |
| ||
![]() | ||||
|
Wednesday, April 2, 2008
The Unix Command Line: Administration
61. Handy Unix Network Troubleshooting Commands
netstat The network status command netstat displays status information about the network interfaces on the host machine and it can display routing table information.
ifconfig The ifconfig command is used to display the local interface configuration (winipcfg for Windows) and to modify the configuration. Local interfaces can be Ethernet network cards, modems, etc..
ifconfig (interface name) (down/up/nothing) nothing gives status route The route command allows you to add static routes to the routing tabling.
route (-n) (add/delete/nothing) (dest IP address/subnet/DEFAULT) (local IP address) (hop)
traceroute (tracert in Windows) Traceroute displays the routers that are passed through to reach the destination.
traceroute "IP address or domain name" | |||
Introduction to Data Communications | ||
---|---|---|
Previous | Table of Contents | Next |
Tuesday, April 1, 2008
Frequently Used Unix Commands
Frequently Used Unix Commands
U-M Information Technology Central Services * R1159 *November 2003
The Unix operating system supports many commands. To review a more complete definition of any of the commands listed below, type man command at the Unix shell prompt (%), where you have replaced command with the name of a Unix command. For example, type man exit to find out more about the exit command.
NOTE: This document assumes you are using Unix on the ITCS Login Service (host name login.itd.umich.edu). These instructions apply to many other Unix machines; however, you may notice different behavior if you are not using the ITCS Login Service.
TIP: The variable files refers to a list of any number of files separated by white space; in the same way; names refers to a list of file or directory names separated by white space.
NOTE: This document is also available in these formats:
Table of Contents
- General
- File System Navigation
- File/Directory Manipulation
- Data Manipulation
- Networking/Communications
- Miscellaneous
- Additional Resources
General
- apropos command
- Locate commands by keyword lookup.
- exit
- Terminate your current session, or shell.
- man command
- Display the Unix manual page describing a given Unix command.
File System Navigation
- cd
- Return to your home directory.
- cd directory
- Change directory to make directory your current directory.
- file files
- Determine file type.
- ls
- List the contents of the current directory.
- ls names
- List the contents of the directories; names can name files and/or directories:
- ls -l
- . . . in a long format, showing permissions, owner, size, and other file info.
- ls -a
- . . . all files, including "hidden" files (file names that begin with a dot ".").
- ls -R
- . . . Recursively, for all subdirectories.
- ls -t
- . . . in time order (when modified, newest to oldest) rather than in name order.
- pwd
- Display the name of the current directory, or "print working directory."
File/Directory Manipulation
- compress files
- Reduces the size of a file.
- uncompress files
- Restores compressed files to their original form.
- cp file1 file2
- Copy file(s).
- cp files directory
- Copy file(s) into a directory.
- cp -r dir1 dir2
- Copy a directory and, recursively, its subdirectories.
- mkdir directory
- Create, or "make" a directory.
- mv file1 file2
- Move a file or, if file1 and file2 are in the same directory, rename a file.
- mv files directory
- Move files into a directory.
- mv dir1 dir2
- If directory dir2 exists, move dir1 into dir2; otherwise, rename dir1 as dir2.
- rm files
- Remove (erase) file(s).
- rm -r names
- Remove files, directories, and recursively, any subdirectories.
- rmdir directory
- Remove directory (directory must be empty).
Data Manipulation
- cat files
- Concatenate file(s); you can use cat to display the contents of a file (this is not advisable if the file is a binary file).
- grep "pattern" files
- Display all lines in the files that match a pattern.
- more files
- Display contents of files one screen at a time.
- sort files
- Order the lines in a file or files alphabetically (this command does not alter the file or files -- it merely displays the sorted output to the screen):
- sort -r files
- . . . in reverse order.
- sort -n files
- . . . numerically (puts 2 before 10 instead of after).
Networking/Communications
- finger user@umich.edu
- Displays information about a U-M user from the U-M Online Directory.
- ssh hostname
- Connect to a remote host using Secure Shell.
- telnet hostname
- Connect to a remote host using the telnet protocol.
- talk user
- Initiate a conversation with another user (end conversation with Control-C); talk works only between machines of the same architecture.
Miscellaneous
- !!
- Repeat last shell command.
- !string
- Repeat last shell command that began with string (for example, type "!m" to repeat the last command that began with "m").
- cal
- Display a calendar of the current month.
- cal month year
- Display a calendar of the given month and year. Note that the year must be fully qualified, for example, "2003" and not "03."
- clear
- Clears terminal screen.
- date
- Display the current local date and time.
- who
- Display a list of users currently logged in.
Additional Resources
Visit ITCS's Information System to obtain ITCS computer documentation and other resources. A list of relevant documents follows.
Idiot's Guide to Basic UNIX Commands - AwkwardTV
Idiot's Guide to Basic UNIX Commands
From AwkwardTV
This is a simple list of commands needed to install applications, plugins or do some other "unixy" stuff on the AppleTV.
Contents[hide] |
[edit] Become root
sudo -s
- sudo will ask for the current user's password, which is "frontrow".
- type "exit" to "undo" being root.
[edit] Kill Finder.app
kill $(ps ax | grep [F]inder | cut -c 1-5)
[edit] Mount/unmount a dmg file
[edit] Unmounting
hdiutil detach /Volumes/
If that doesn't work:
hdiutil detach -Force /Volumes/
[edit] Mounting
hdiutil mount someimage.dmg
[edit] Remount your root (/) file system read/write
- needs to be executed as root user (see above)
mount -rw /
[edit] Move files around
- might need to have the root file system mounted in read/write mode
mv /file/you/want/to/move /target/location/
[edit] Start shlight
- needs shlight installed
- if problems arise, please first add the servername to
/etc/hosts
(see below)
/usr/sbin/shlight /// /Users/frontrow/Movies/somemountpoint
[edit] Add a host to /etc/hosts
echo -e "\t " >> /etc/hosts
[edit] Get a screen capture of your AppleTV
screencapture -s filename.png
macosxhints.com - Mount .DMG images remotely via the Terminal
$ cat HeadlessInstall.txt
10 August 2004 Brett Johnson
This describes some of the steps necessary to perform the
installation of Mac OS X packages via the command line.
1) Download the Package"
Download the installation image to a local directory.
I usually download packages to the ~admin/staging directory [a client convention].
Don't try to download it to some target directory like /etc or /usr
I use 'curl' to fetch the package from the net. I usually Ctrl-click
or right-click the package link in Safari (running locally) and select
'Copy link to Clipboard'. This copies the URL to the package to the
clipboard. I then paste the URL into the curl command in a ssh login
window to this server. Note that curl writes its output to stdout,
so be sure to redirect it to a file. For example
% curl http://www2.entropy.ch/download/Entropy-PHP-4.3.6-4.dmg > Entropy-PHP-4.3.6-4.dmg
This DOESN'T work for things on SourceForge, where the links are actually
javascript that goes to a mirror. In that case, download it locally,
then use sftp (or Fugu) to move it to this server.
2) If it is a compressed archive, decompress it using the appropriate tool.
For instance suppose you have a .tar.gz file:
% ls
xyzzy.pkg.tar.gz
% gunzip xyzzy.pkg.tar.gz
% tar -xvf xyzzy.pkg.tar
3) If it is a disk image file (.dmg) mount it using hdid. By default,
the disk images are mounted under the /Volumes directory. I see no
reason to do otherwise.
% hdid Entropy-PHP-4.3.6-4.dmg
% ls /Volumes
Backup HD Entropy PHP 4.3.6-4 Server HD
% cd "/Volumes/Entropy PHP 4.3.6-4"
% ls
Documentation.html php-4.3.6.pkg
4) Run the command line version of the Mac OS X installer. By default
the installer produces terse output suitable for parsing by scripts
doing installations. We will make the output verbose [human readable].
The installer takes the package name as well as the target Volume.
The installer is /usr/sbin/installer , which should be on the path.
The installer must be run as root, so be prepared to sudo...
% sudo /usr/sbin/installer -verbose -pkg php-4.3.6.pkg -target /
5) Don't forget to unmount the .dmg disk image if you mounted one.
Here we execute the 'mount' command to determine which virtual
disk device our dmg is mounted as (in this case it is /dev/disk2s2).
Then we use 'hdiutil detach' to unmount it.
% mount
/dev/disk0s3 on / (local, journaled)
/dev/disk1s3 on /Volumes/Backup HD (local)
automount -nsl [336] on /Network (automounted)
/dev/disk2s2 on /Volumes/Entropy PHP 4.3.6-4 (local, nodev, nosuid, read-only, mounted by admin)
% hdiutil detach /dev/disk2s2 -force
"disk2" unmounted.
"disk2" ejected.