This article provides basic overview of UNIX commands used on the NetScaler system and basic commands for the vi editor.
Getting to the Shell Command Prompt
To get to the shell, type shell at the NetScaler CLI. To return back to the NetScaler CLI, type exit.
When in the shell, the following tips will help simplify typing and navigation:
Use the up or down arrow keys to use previous or next commands.
Use the Tab key to auto complete a command or filename.
Press the Tab key twice to see the available commands or filenames that match what is typed so far.
Use the history command to show all commands that are previously used.
Use the exclamation (!) symbol to execute a particular history ID. For example, !362.
Common Commands for Directories
pwd – Shows the current directory.
cd – Changes the directory to a parent directory or a subdirectory.
rooot@ns# cd /var/nstrace/
Changes to the /var/nstrace/ directory from any point because it is explicitly from the /.
root@ns# cd ..
Changes to the parent directory.
root@ns# cd nstrace
Changes directory to nstrace from current directory.
ls – Used for listing content such as files and subdirectories in the current directory.
root@ns# ls –al – List files, directories and link with the following detail.
root@ns# ls –al
drwxr-xr-x 2 root wheel 3072 Feb 15 15:05 .
drwxr-xr-x 29 root wheel 512 Feb 14 2005 ..
-rw-r–r– 1 root wheel 15370 Feb 13 15:05 dmesg.boot
-rw-r–r– 1 root wheel 15370 Feb 13 13:22 dmesg.last
-rw-r–r– 1 root wheel 15374 Feb 9 14:39 dmesg.prev
-rw-r–r– 1 root wheel 98592 Feb 17 10:03 newnslog
-rw-r–r– 1 root wheel 23194 Feb 7 09:29 newnslog.0.gz
-rw-r–r– 1 root wheel 23786 Feb 9 09:30 newnslog.1.gz
-rw-r–r– 1 root wheel 10086 Aug 2 15:53 newnslog.10.gz
permissions, owner, group, size, creation date and file name.
root@ns# ls –ltr – List files, directories sorted by date/time with the latest being the last.
root@ns# ls –ltr
-rw-r–r– 1 root wheel 29517 May 2 2005 ns.reboots
-rw-r–r– 1 root wheel 752 May 2 2005 nslog.log
-rw-r–r– 1 root wheel 1702764 Aug 14 2005 newnslog.7.gz
-rw-r–r– 1 root wheel 1126553 Aug 16 2005 newnslog.8.gz
-rw-r–r– 1 root wheel 1191421 Aug 18 2005 newnslog.9.gz
-rw-r–r– 1 root wheel 1003186 Aug 20 15:53 newnslog.10.gz
-rw-r–r– 1 root wheel 1127304 Aug 22 15:53 newnslog.11.gz
-rw-r–r– 1 root wheel 1563115 Aug 24 15:53 newnslog.12.gz
root@ns# cd ../../../opt – Changes to the parent of the parent of the parent and to the opt subdirectory in one command.
root@ns# cd ~ – Changes directory to the users home directory from any where.
date – Used to get the date and time of a UNIX/Linux system.
Tue Nov 9 12:34:14 EST 2004
ifconfig – Displays the kernel-resident network interfaces.
root@ns# ifconfig –a
lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000 hme0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4>mtu 1500 index 2
inet 10.3.1.59 netmask ffff0000 broadcast 10.3.255.255 ether 8:0:20:f9:9:14
ps – Used for listing the process running on the system. ps has many switches –ax will show the most popular information.
Note: The ps command output on NetScaler does not correctly represent the process values. This is normal and great emphasis should not be placed on its output when determining the system status and load.
root@ns# ps -ax
|root||1||0||0||Nov 17||?||0:00||/etc/init –|
|root||292||1||0||Nov 17||?||0:00||/usr/lib/saf/sac -t 300|
cat – This command is used to display the content of a text file. By default this command gives one full screen of text.
root@ns# cat /etc/hosts
10.3.1.59 fltr-user1-sol1 loghost
zcat – This command is used to display the content of a text file that is compressed by gzip that has the “.gz” extension. By default this command gives one full screen of text.
root@ns# gzcat /etc/hosts.gz
10.3.1.59 fltr-user1-sol1 loghost
less – This command is used to display the content of a text file and will allow you to scroll backwards and forwards in the file using the arrow keys.
grep – Searches the named input file(s) for lines containing a match to the given pattern.
cat <file> | grep <match>
root@ns# more ctxXtw.sh | grep ctxXtw
# ctxXtw launcher
# See the file ctxXtw.readme.
tail – Displays the last 10 lines of a text file.
root@ns# tail /etc/hosts
root@ns# tail -50 /etc/hosts
You can specify a number of last lines to display by -<num>.
root@ns# tail -f /var/log.file
You can use tail to monitor a text file as it is being modified with the –f.
history – This command lists all shell commands that were previously issued.
1 netstat –rn
3 cd /etc
5 cd group
You can use the exclamation (!) symbol with a history ID to issue the command.
Note: For more information, refer to the NetScaler Administrator’s Guide.