linux-unix

recent posts related to linux and unix

Linux alias command examples

Unix and Linux aliases are a really nice way of customizing the command line to work the way you want it to work. With alias commands, you're essentially doing a little programming, and creating new Unix and Linux commands custom-tailored to the way you work. You can create aliases to use instead of existing commands, and you can also create aliases as Linux command pipelines.

Linux shell script heredoc example

I was just working on my Linux Teleport command (Linux cd command with a history), and ran across the code below, which essentially shows how to use a form of "heredoc" syntax in a Bash shell script. This approach uses the Linux cat command, but functions just like the heredoc syntax in languages like Perl.

Here's the source code I just came across:

vim word completion - automatic word completion in the vim editor

vi/vim FAQ: How do I use the vim completion (word completion) feature?

When using the vi/vim editor I'm surprised how many people don't use its built-in vim completion (vim auto complete or vim code complete) feature.

awk column example - print columns from a text file

Printing columns of information from text files is easy, especially using tools like awk, perl, and more recently, ruby. Here's my old school awk way of doing this.

awk column printing examples

Suppose you have a file named foo with contents like this:

Linux find command - reverse the meaning of a file search

Summary: How to reverse the meaning of a Linux find command.

I spent last night doing a bunch of work on my source code warehouse. At the end of the night I needed to do a search for all files in many subdirectories whose filenames did not end with "*.java". It's easy enough to find filenames that do end with "*.java", using the find command like this:

Use Linux scp without a password to make remote backups

Summary: How to create a public and private key pair to use ssh and scp without using a password, which lets you automate a remote server backup process.

Over the last two years I've ended up creating a large collection of websites and web applications on a variety of Linux servers that are hosted with different companies like GoDaddy and A2 Hosting. I recently embarked on a mission to automate the backup processes for all these sites, and as a result of this effort, I thought I'd share what I've learned here.

dig commands and examples

dig command FAQ: Can you share some dig command examples?

I was just trying to help a friend troubleshoot some email server problems at his company, and had to use the Linux dig command a lot to try to determine what was wrong. In the end it turned out that his company bought a block of IP addresses that were blacklisted, but in the middle I had some fun trying to remember how to use the dig command again.

How to read shell script command line arguments

Unix/Linux shell script args FAQ: How do I access Unix or Linux shell script command line arguments?

If you're just expecting one or two parameters to be passed into a Unix or Linux shell script, and these parameters aren't options/flags to your script (like "-a" or "-f"), you can access the shell script arguments through variables named $1, $2, etc.

Here's a short example where I'm expecting two shell script command line arguments. If either of these command line arguments is blank, I display a usage statement and exit my script:

Linux shell script date formatting

Linux date FAQ: How do I create a formatted date in Linux? (Most likely, "How do I create a formatted date I can use in a Linux shell script?")

I just ran into a case where I needed to create a formatted date in a Linux shell script, where the date format looks like this:

2010-07-11

To create this formatted date string, I just used the Linux date command, using the "+" sign to specify that I want to use the date formatting option, like this:

Linux processor and memory information commands

Linux FAQ: How can I find Linux processor and memory information? (Also written as, How can I find Linux CPU information?, How can I find Linux RAM information?)

To see what type of processor/CPU your computer system has, use this Linux processor command:

cat /proc/cpuinfo

As you can see, all you have to do is use the Linux cat command on a special file on your Linux system. (See below for sample processor output.)

To see your Linux memory information and memory stats use this command:

Syndicate content