Basic UNIX Commands for NetScaler

Basic UNIX Commands for NetScaler

book

Article ID: CTX109262

calendar_today

Updated On:

Description

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.

Example:
root@ns# pwd
/var/nstrace/
root@ns#

cd  - Changes the directory to a parent directory or a subdirectory.

Examples:
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.

Examples:
root@ns# ls –al 
- List files, directories and link with the following detail.
root@ns# ls –al
total 643611
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.

Example:
root@ns# ls –ltr
total 643223
-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.

Example:
root@ns# date
Tue Nov  9 12:34:14 EST 2004

ifconfig  -  Displays the kernel-resident network interfaces.

Example:
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.

Example:
root@ns# ps -ax

UID  PIDPPIDCSTIMETTYTIMECMD
root000Nov 17?0:17sched
root100Nov 17?0:00/etc/init -
root200Nov 17?2:47pageout
root300Nov 17?0:00fsflush
root29210Nov 17?0:00/usr/lib/saf/sac -t 300
root21910Nov 17?0:00/usr/lib/utmpd

cat – This command is used to display the content of a text file. By default this command gives one full screen of text.

Example:
root@ns# cat /etc/hosts
127.0.0.1       localhost
10.3.1.59       fltr-user1-sol1      loghost
10.3.10.2       fltr-user1-1 

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.

Example:
root@ns# gzcat /etc/hosts.gz
127.0.0.1       localhost
10.3.1.59       fltr-user1-sol1      loghost
10.3.10.2       fltr-user1-1

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>

Example:
root@ns# more ctxXtw.sh | grep ctxXtw
# ctxXtw launcher
# See the file ctxXtw.readme.
XTW=${1}ctxXtw 

tail – Displays the last 10 lines of a text file.

Examples:
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.

Example:
root@ns# history
1              netstat –rn
2              exit
3              cd /etc
4              ls
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.

Issue/Introduction

This article is designed to provide a basic overview of UNIX commands used on the NetScaler system. This guide also includes basic commands for the vi editor.