Home > AS/400 Tips > iSeries administrator tips > Linux for IBM i: Commands and terminology
iSeries 400 Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ISERIES ADMINISTRATOR TIPS

Linux for IBM i: Commands and terminology


David Vasta, Contributor
10.16.2008
Rating: -5.00- (out of 5)


iSeries news and advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


In part one, David Vasta introduced Linux to the IBM i person. Here he explains Linux terminology and commands to the novice. Part three covers authorities and permissions on Linux.

[IMAGE]

I hear Linux is hard, and is for geeks… I am not a geek, so is it still for me?

Of course you're not...

Now that we have cleared that up let's get into how we're going to "talk" to Linux. Linux talks to us people using a shell. It's that green or text-based screen that we i users are familiar seeing. I, of course like the shell sometimes much more then I do some GUI application, but have been known to use a GUI and smile at times. The shell is just a layer that is between you the user or administrator and the kernel.

What is a shell?
A Unix shell is a command language interpreter, the primary purpose of which is to translate command lines typed at a terminal into system actions. The shell itself is a program through which other programs are invoked. Although there are several different Unix shells, among them the C shell (csh), the Bourne shell and the Korn shell, the one most frequently used on Blake within Berkeley UNIX is the C shell.

Getting started in the shell
Since Linux has very few built-in commands, you (the user) will be needing a shell to get information from the system and direct information to the system. When you telnet into any Linux box you will be given a shell once you log in and that shell is determined with your user profile.

Getting started using Linux commands
The sidebar list gives you a decent set of commands to start with. You can build on that with more commands and take commands and join them together. Using a pipe you can have commands take their output and push it to another command. It's one of the most powerful parts of the Linux tools.

Example:

who | sort > file

This would take the output of who then pipe the data to the sort command and then place that in a file


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
iSeries administrator tips
Translating Linux for IBM i admins: Using GUI to make it easy
Translating Linux for IBM i admins: Working with jobs and networking
OpenOffice: What to know before making the transition from Microsoft Office
OpenOffice: An enterprise open source solution
Database performance comparisons on IBM i
Translating Linux for IBM i admins: User profile commands
Modern System i reports using Client Access
Tips for installing Lotus Domino server on a System i partition
The iSeries Blog has a new home on IT Knowledge Exchange
Virtualization for IBM i: Backups

Linux on iSeries
Translating Linux for IBM i admins: Using GUI to make it easy
Translating Linux for IBM i admins: Working with jobs and networking
OpenOffice: What to know before making the transition from Microsoft Office
OpenOffice: An enterprise open source solution
Translating Linux for IBM i admins: User profile commands
Linux for IBM i: Authorities and permissions
Linux for IBM i: Introducing Linux to IBM i people
Fast guide to logical partitioning
Looking at LPAR
Server consolidation, virtualization give U.S. Open the advantage

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


called "file."

cat file > newfile | grep 'searchstring' newfile

This string of commands would do the following: Cat command would output the contents of a the file to newfile then take the newfile and search it using grep for the search string you want of the file called newfile. This will replay on the screen unless you then pipe the output to a file like this:

cat file > newfile | grep 'searchstring' newfile > grepinfo

Redirection
Because this is important, I make sure we cover it here, thoroughly. Redirection is simple, and here is the list again in a consolidated version for easy reference.

>: Redirects output

<: Redirect input

>>: Redirects output and appends it

|: Pipe command and pipes data to other commands

>&: Redirects both standard output and standard error

2>: Redirects only standard error

/dev/null: This is a special place to send things to be lost forever. It's usually a place for getting rid of output.

Types of redirection: Linux for the most part uses three standard types of redirection:

stdin: Standard input, keyboard

stdout: Standard output, screen

stderr: Standard error, screen

You can of course redirect any of these to pretty much any place. Examples:

Standard output is redirected through use of '>'

dir mydir > filelist.txt

Standard error is redirected through use of '2>' construct

find / -name core -print 2> /dev/null

Standard input is redirected through use of '<'

isql < build_mydb.sql

It is pretty simple stuff once you get use to the way commands are clumped in order to do very powerful things. I sometimes find myself wishing I could type "WRKACTJOB" and then use the '|' to get the data out that I want – now, that would be powerful. This would be cool, but you can't actually do it:

WRKACTJOB > actjobs.txt | sort | grep QSECOFR actjobs.txt > found.txt

You may be wondering why is understanding this is important. Well, if you are a Linux administrator you're going to need these tools and commands at your finger tips. I know you can pretty much Google anything at this point, but it's always handy to have a nice firm base when you log on to start working on problems and delivering solutions.

Slicing and dicing the data
I am going to once again lay out some more very interesting concepts and commands that will help you with your Linux Administration work.

Refer to the following commands: HEAD, TAIL, CUT, SORT, UNIQ, GREP, and WC. Now we'll dig a little deeper into these commands to make sure we get the most out of them.

Heads and tails: Because these commands are like peanut butter and jelly we are going to cover them together.

The head command can be used to display the start of a file. By default the top 10 lines of the file will be displayed

head /var/log/messages

The tail command is the reverse of the head command will by default print the bottom 10 lines of the file

tail /var/log/messages

Both the head and tail commands support the option of indicating how many lines to display

tail -20 /var/log/messages

The tail command can also be used to display updates to files (such as log files) as they are made. This is accomplished with the –f option

tail –f /var/log/messages

Cut: Cut is an interesting command, although it is one that I don't use often. The cut command is one that some people love, and some people can live without (I'm one of the latter). It's one of those commands you have to pipe information to so it sometimes gets lost in the mix; but if used properly, it can be a nice little command to have in your bag.

[TABLE]

UNIQ and SORT: The commands UNIQ and SORT and can be used together to find unique entries from standard input:

UNIQ: Analyzes standard input, and removes all duplicate/repeating entries

SORT: Sorts standard input and provides a sorted list to standard output

[TABLE]

WC: The wc (word-count) program can be used to count the number of characters, words, and lines from standard input:

[TABLE]

Alias: Alias is command that is used mostly in your .profile. It's a power-user type of command -- a command that says "I know what the heck I am doing." Typically, alias is used to abbreviate other longer commands. For example I love the System i and wanted to tinker so I type the command TOP, which shows processes and CPU utilization and made an alias for it in my .profile that was quicker for me to type, WRKACTJOB. I know it's more letters but after typing that for 18 years I have to hunt and peck for TOP plus it's just geeky. How I did this:

alias wrkactjob=top

Multitasking: So you may have heard that Linux is a "real" multitasking operating system -- it truly is. Here are some things you might want to know about starting and stopping jobs that are on your multitasking operating system: [TABLE]

Process control: Each job or process on a system has a process identification number (PID). Each of these processes has a parent process called a PPID. The PID is important as this is the way many tasks and other operating-system-level items keep track of jobs running on the system.

Your "main MAN": From time to time you will hear a very rude administrator or support desk person tell you to RTFM, and we all know that is not a very nice thing to say unless you just handed them a manual with all the world answers in it, then of course it's time to RTFM.

The "MAN" command is a new users best friend. MAN is short for manual, hence my digression in the previous paragraph. You can MAN any command in the operating system as long as the MAN is loaded. Here is how that works.

man ls

[IMAGE]
Click on image for larger version

man top

[IMAGE]
Click on image for larger version

These two commands will give you all kinds of ways to use the commands you have questions about. There is also an INFO command, but I would start with man.

File Management: ls -li smb.conf [IMAGE]

iNODE Authority Links Owner Group Size Modified Date File Name

ABOUT THE AUTHOR: David Vasta is the Lotus Notes Administration Team Lead over North America at Atlas Copco. He has 17 years of data center and iSeries experience working in companies such as IBM, REAL and Cingular. He writes a regular blog at System i blogger.

Rate this Tip
To rate tips, you must be a member of Search400.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



iSeries Security - Security Tools, Physical Security and System Security
HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts