linux-unix

recent posts related to linux and unix

The Linux file command

Linux file information FAQ: How can I tell what type of file a file is on a Unix or Linux system?

The Linux "file" command shows you the type of a file, or multiple files. It's usually used when you're about to look at some type of file you've never seen before. When I first started working with Unix and Linux systems I used it a lot to make sure I wasn't about to open a binary file in the vi editor, amongst other things.

You issue the Linux file command just like other commands, like this:

The Linux who command

The Linux "who" command lets you display the users that are currently logged into your Unix computer system.

The basic who command with no command-line arguments shows the names of users that are currently logged in, and depending on which Unix/Linux system you are using, may also show the terminal they're logged in on, and the time they logged in.

who

Since I'm the only one logged into my Linux system right now, I see output like this:

The Linux pwd command (and Linux command line prompts)

Linux current directory FAQ: How do I show what directory I'm currently in on a Unix or Linux system?

Just use the Unix/Linux pwd command, like this:

pwd

If you're in a directory named /home/al, the output looks like this:

$ pwd
/home/al

Putting the current directory in your Linux prompt

In the old days we had to type this command all the time, but in these more modern times we can just display the current directory in our prompt symbol by setting it like this:

The Unix compress command

The Unix "compress" command is rarely used any more, and has largely been replaced by the Unix/Linux gzip and bzip2 commands. However, on some Unix systems the compress command is still used, so for them, here are a few Unix compress command examples.

Unix compress command examples

The following command will compress the file named foo.tar into a new file named foo.tar.Z:

compress foo.tar

This command compresses the file named foo.tar, and replaces it will a file named foo.tar.Z. (Your original foo.tar file will no longer exist.)

The Unix/Linux lpstat command

The Linux lpstat command lets you look at the progress of your print request(s). The name "lpstat" stands for "line printer statistics".

lpstat command examples

The "lpstat" command, used with no options, may return no output if there are no print jobs queued.

The Linux lp printing command

The lp command is used to print files on Unix and Linux systems. The name "lp" stands for "line printer". As with most Unix commands there are a fairly large number of options available to enable flexible printing capabilities.

Let's look at some lp printing commands examples.

Linux lp printing command examples

lp /etc/passwd

This command prints the "/etc/passwd" file to the default printer. If you do not use the "-d" option, the file is printed to the default printer destination.

The Linux cancel command (cancel a print job)

The Linux "cancel" command lets you stop print requests from printing (cancel them).

Linux printing requests can be canceled by either (a) using the printer-id or (b) by specifying the printer name. Here are examples of each approach.

cancel laser-101

This first command cancels the print request identified as "laser-101". (You would have gotten this identifier using an lpstat command.

An Apache name based virtual host (NameVirtualHost) tutorial

Apache virtual hosting FAQ: How do I configure Apache to run multiple virtual hosts (name-based virtual hosts)?

An Apache name-based virtual host (NameVirtualHost) tutorial: As a quick reminder to myself for something I just did using MAMP on my Mac OS X system, here's how I configured the MAMP Apache server to use name based virtual hosting for two websites that I'm developing at the same time.

Process every line in a file with this Unix/Linux shell script

Unix/Linux shell script FAQ: How do I write a Unix or Linux shell script where I "do something" for every line in a text file?

Solution: An easy way to process every line in a text file is to use a Unix/Linux while loop in combination with the Linux cat command, like this:

The Linux top command

Linux top command FAQ: Is there a utility to show Linux processes interactively, like the Unix/Linux ps command, but more like a GUI ro character-based interactive tool?

Syndicate content