Unix Commands
Unix 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 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)
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:
page 5 of 7
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
Command to view le contents: % cat [filename] Command to view compressed le (le with .gz extension): % zcat [filename]
page 7 of 7