Tag: how to use linux

By Erick M Aqqa

Unix based operating systems like Linux offer a unique approach to join two discrete commands, and generate a new command using the concept of pipe(lines). For example, consider command1|command2. Here, whatever output is generated by the first command becomes the standard input for the second command. We can develop more and more complex Unix command sequences by joining many commands while maintaining input output relationships.

Another more Linux specific example would be ls -l|grep “^d”. This command displays details of only directories of the current working directory, i.e. the output of the ‘ls -l’ command becomes the input to the grep command, which displays only those lines that start with ‘d’ (they are nothing but the details of the files).

ls -l | grep “^d” | wc -l

This command displays number of directories in the given file.

grep “bash$/ etc / passwd | wc -l

This command displays number of users of the machine whose default shell is bash.

cut -t “: “-f 3 / etc / passwd | sort – n | tail – l

This command displays a number which is the largest used UID number in the system. Here, cut command first extracts UID’s of all the users in the system from the /etc / passwd file, and the same becomes input to sort; which sorts these numbers in numerical order and sends to tail command as input which in turn displays the largest number (last one).

tee command

The ‘tee’ command is used to save intermediate results in a piping sequence. It accepts a set of filenames as arguments and sends its standard input to all these files while giving the same as standard output. Thus, use of this in piping sequence will not break up the pipe.

For example, if you want to save the details of the directories of the current working directory while knowing their using the above piping sequence we can use tee as follows. Here, the file xyz will have the details of the directories stored.

ls -l | grep “^d” |tee xyz | wc -l

The following piping sequence writes the number of directories into the file pqr while displaying the name on the screen.

ls -l | grep “^d” | tee xyz | wc -l |tee pqr

cmp command

The cmp utility compares two files of any type and writes the results to the standard output. By default, cmp is silent if the files are the same. If they differ, the byte and line number at which the first difference occurred is reported.

Bytes and lines are numbered beginning with one.

For example, cmp file1 file2

comm command

comm is a command used to compare two sorted files line by line.

Compare sorted files LEFT_FILE and RIGHT_FILE line by line.

-1 suppresses lines that are unique to the left file.

-2 suppress files that are unique to the right file.

-3 suppress lines that appear in both the left file and the right file. For example, comm p1 p2.

A pipe thus helps connect a set of processes, so that the output of one becomes the input of another. It lets a user browse through a large amount of data in a convenient manner.

Linux2Aix is an upbeat Linux blog containing all the latest and the newest Linus news and how-to’s for both amateur and professional Linux lovers

Tags: , , , , , , , , , , , , ,

By Clyde E. Boom

Linux Commands – The great thing about Linux commands is that they are virtually identical from one Linux distribution (version) to another. So the way the real pros do Linux administration is to work at the Linux command line and run Linux command lineLinux commands.

Learning how to run a Linux command can be very difficult for someone new to Linux, so here are some Linux tips that will help you to learn how to use Linux commands when working at the Linux command line prompt.

There are three main parts of a Linux command:

1. The Linux command name

2. Options that can be used with the Linux command

3. The “item(s)” that the Linux command is being run “on”

When you run a Linux command, spaces are used between: the Linux command name, the command options and the “item” the command is being run “on”. The “item” could be a Linux directory, file, user or some other Linux software component.

For example, you run the Linux command named ls (for list) “on” a Linux directory to see a list of files in the directory. You run the Linux command named rm (remove) “on” a Linux directory to remove the directory from the Linux file system.

To run a Linux command, you type in the name of the command, and any other parts of the command, such as options, and press the Enter key.

You can see an example of the Linux command that is used to create a new Linux user below. The useradd command is being run “on” the bthatcher user name to create this Linux user.

Linux Tips: Linux commands are run at the Linux command line prompt and this prompt is shown as ]# at the left of the command. You don’t type in the prompt, you type the Linux command at the right of the prompt.

Linux Tips: The Linux command prompt may also appear as: ]$ or as another symbol, instead of # or $.

]# useradd -c “Becky Thatcher” bthatcher

This Linux command creates a new Linux user named bthatcher with the full name of “Becky Thatcher”. The -c (for comment) option is used with this command to add the full name as a comment to the Linux user name of bthatcher.

One of the easiest and best ways to get Linux training is to see Linux commands being run in Linux video tutorials. With this method – you see, hear and do.

With a Linux video tutorial, you see and hear how to run a Linux command and see and hear a description of the output of the command. You can also pause the video so you can run the Linux command yourself!

Copyright ©  Clyde Boom

Clyde Boom, Author and Expert Trainer with 20+ Years of Training Successes. Explains intricate technical matters in an easy-to- understand, non-technical manner, with tens of thousands of software and hardware learners into masters.

You can watch Free Sample I Learn Linux Video Tutorials at http://www.iLearnLinux.com and get over the steep Linux learning curve.

Sign up for Free I Learn Linux News to receive technical tips, info on new video samples and important updates on Linux.

You need to learn Linux the easy way to get that new job, qualify for that next promotion, earn a hefty raise, get Linux certification, or keep your current job because your company is trying to save on software licensing fees (eza). Watch, do, and learn!

Tags: , , , , , , , , , , ,
Back to top