0% found this document useful (0 votes)
102 views7 pages

Unix Commands

The document provides information on commands for navigating and viewing information on a Unix system. It includes commands for accessing the Unix shell from the CLI, viewing processes and network traffic, navigating directories, finding file locations, and viewing file contents. Specific commands summarized include top to view real-time process info, iftop to view network interfaces, ls to list directory contents, and cat/zcat to view file contents.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
102 views7 pages

Unix Commands

The document provides information on commands for navigating and viewing information on a Unix system. It includes commands for accessing the Unix shell from the CLI, viewing processes and network traffic, navigating directories, finding file locations, and viewing file contents. Specific commands summarized include top to view real-time process info, iftop to view network interfaces, ls to list directory contents, and cat/zcat to view file contents.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 7

Commands

To access Unix prompt from cli (operational mode command): user@tokyo> start shell (if logged in as root, you start at the unix shell) Unix shell prompt: % To return to CLI from unix shell: % cli Command to view process memory and cpu usage in real time: % top Snapshot of top output:

(ctrl+c will exit out of running process and return you to the command prompt)

page 1 of 7

Equivalent command in the cli (displays snapshot, not real-time): user@tokyo> show system processes extensive Command to give snapshot of process usage: % ps -aux Using a piped command to match a parameter (grep is the Unix equivalent of the JUNOS match command, the example uses the rpd parameter): % ps -aux | grep rpd Command returns the following les that contain rpd:
root 22648 root 2856 0.0 0.0 0.2 0.8 2832 2268 9144 8244 ?? ?? S S Sun01PM 2Nov09 0:25.28 /usr/sbin/vrrpd -N 1:17.09 /usr/sbin/rpd -N

Command to display hostname and other OS details: % uname -a Command output


JUNOS Tokyo 8.1R2.2 JUNOS 8.1R2.2 #0: 2006-12-16 02:54:19 UTC builder@vouivre.juniper.net:/build/vouivre-c/8.1R2.2/obj-i386/sys/compile/JSERIES i386

Command to display boot messages and kernel errors: % dmesg Equivalent cli command (displays CPU type, memory and peripheral information): user@tokyo> show system boot-messages Sample output: Line displaying installed memory:
real memory = 1073741824 (1048576K bytes) (Installed memory)

Line displaying CPU type:


CPU: Intel(R) Celeron(R) CPU 2.53GHz (2533.44-MHz 686-class CPU)

Line displaying keyboard driver (atkbdc0):


atkbdc0: <Keyboard controller (i8042)> at port 0x60,0x64 on isa0

page 2 of 7

Command to display physical slices (File Systems): % df some switches for df command: -h (human readable format, display sizes in kilobytes and megabytes) -H (displays sizes in multiples of 1000) Equivalent cli command: user@tokyo> show system storage Sample output of show system storage command:
Filesystem /dev/ad0s1a devfs /dev/vn0 /cf devfs /dev/bo0s1e procfs mfs:54 mfs:2432 mfs:2434 mfs:2436 mfs:2438 Size 852M 16K 106M 852M 16K 95M 4.0K 165M 46M 7.7M 23K 1.9M Used 47M 16K 106M 47M 16K 6.0K 4.0K 6.6M 26K 91K 1.0K 2.0K Avail 797M 0B 0B 797M 0B 94M 0B 146M 43M 7.0M 21K 1.8M Capacity 6% 100% 100% 6% 100% 0% 100% 4% 0% 1% 5% 0% Mounted on / /dev/ /junos /junos/cf /junos/dev/ /config /proc /mfs /jail/tmp /jail/var/etc /jail/dev /jail/html/oem

Command to display packets in and out of default interface (management interface) This command can only be executed in the shell by the root user account: root@tokyo% tcpdump Equivalent cli command: user@tokyo> monitor traffic Sample output of unix tcpdump or cli monitor traffic command (note interface ge-0/0/0 specied in the second line of the output):
verbose output suppressed, use <detail> or <extensive> for full protocol decode Listening on ge-0/0/0, capture size 96 bytes 20:34:09.928346 In arp who-has 192.168.0.1 tell 192.168.0.1 20:34:11.198566 In 802.1d unknown version 20:34:11.948324 In arp who-has 192.168.0.1 tell 192.168.0.1 ^C 3 packets received by filter 0 packets dropped by kernel

page 3 of 7

To use tcpdump to display trafc on a specied interface (example used, ge-0/0/3): root@tokyo% tcpdump -i ge-0/0/3 Equivalent cli command to monitor trafc on a specied interface: user@tokyo> monitor traffic interface ge-0/0/3 Both the unix command tcpdump and the cli command monitor trafc can be used with a write to le switch to capture the output to a specied le: root@tokyo% tcpdump redirect filename user@tokyo> monitor traffic write-file filename Command to monitor all interfaces in real time: % iftop Snapshot of iftop output:

Equivalent cli operational mode command: user@tokyo> monitor interface traffic


page 4 of 7

File Navigation Commands


List contents of current directory: % ls Some witches available for ls command: -l (long view, shows detailed information about les including permissions, owners, size, modied time, whether the item is a le, directory or link, etc...) -F (marks items listed with identifying symbols, for example, directories are marked with a trailing slash (/), executables marked with a trailing asterisk (*)) Show current directory (present working directory): % pwd To change to another directory: % cd [path] Example: % cd / (To go root directory of current drive) % cd .. (to go up one level in directory structure) % cd /var/log (to go to /var/log directory) % cd (entered with no parameters will return you to the home directory for the logged in user)

File and Data Locations


Location of kernel level application les: /bin Location of system level application les: /sbin Location of conguration les, including the active conguration, the rst 3 rollback congurations and rescue conguration: /config

page 5 of 7

Contents of /config using ls -l command:


-rw-r-----rw-r-----rw-r-----rw-r-----rw-r----1 1 1 1 1 root root root root root wheel wheel wheel wheel wheel 1020 1021 968 862 956 Nov Nov Nov Nov Oct 24 24 24 24 27 11:25 03:45 03:39 12:51 03:29 juniper.conf.1.gz juniper.conf.2.gz juniper.conf.3.gz juniper.conf.gz rescue.conf.gz

Location of rollback conguration les 4 through 49: /var/db/config FreeBSD conguration le: /etc/rc.conf Location of Routing Protocol Deamon (rpd): /usr/sbin/ Command to nd executable le (i.e. the rpd deamon): % which rpd Location of temporary les (location of crash les if crash occurs): /var/tmp Location of log les: /var/log System log messages le: /var/log/messages (System by default stores 10 log les each 10 megabytes in size.) Conguration for storing logs is located in the active conguration under the [edit system syslog] stanza.
[edit system syslog] lab@Tokyo# show user * { any emergency; } file messages { any any; authorization info; } file interactive-commands { interactive-commands any; } file cli-commands {

page 6 of 7

interactive-commands info; } [edit system syslog] lab@Tokyo#

File Specic Commands


Displaying the contents of the rc.conf le: % cat rc.conf Abbreviated output of cat rc.conf command:
#!/bin/sh # # This is rc.conf - a file full of useful variables that you can set # to change the default startup behavior of your system. # # All arguments must be in double or single quotes. # # rc.conf,v 1.1.2.40 1998/03/15 16:39:41 jkh Exp ############################################################## ### Important initial Boot-time options ##################### ############################################################## swapfile="NO" # Set to name of swapfile if aux swapfile desired. apm_enable="NO" # Set to YES if you want APM enabled. pccard_enable="YES" # Set to YES if you want to configure PCCARD devices. pccard_mem="DEFAULT" # If pccard_enable=YES, this is card memory address. pccard_ifconfig="NO" # Specialized pccard ethernet configuration (or NO). debugger_on_panic="NO" # If DDB, drop into debugger if system panics debugger_on_break="NO" # If serial console & DDB, <break> puts you into DDB mirror_flash_on_disk="NO" # Mirror flash disk on hard disk for redundancy logoff_console_on_disconnect="NO" # Log out console session when disconnected

Command to view le contents: % cat [filename] Command to view compressed le (le with .gz extension): % zcat [filename]

page 7 of 7

You might also like