ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

How to not suck at unix

Updated on July 7, 2010

In the beginning...

 This quick guide is intended for the beginning Unix or Linux user.  This is typicaly a Computer Operator at a business or maybe a student. 

This isn't a tutorial, you should probably have a book if you find yourself in this situation.

This is to show some of the common pitfalls I see and what to do.

Training? Yeah ok...

If you are a beginning UNIX user and you now have to use it for your job, you will benefit from bugging a knowledgeable user quickly. This may be someone who has your position, a Systems Administrator, a Developer. Keep in mind not all of these people may know much, you have to figure this out as you go, don't just go by job title.

We will assume you know how to login and have access to a prompt for the next section. You should have some familiarity with basic commands and using an editor to edit files ( on the system.

Alias rm!

Most of the UNIX snobs will not give this advice, but as a beginning operations person who isn't using a menu, this is advised so you don't trash files you didn't mean to.  Identify your shell if you don't know it, "echo $SHELL".  This should be bash, tcsh, ksh.  If it's sh then you may need to ask your System Administrator for a better option.

Each of these can be configured with a file in your home directory, a hidden file (this is a file that starts with a dot (.), you don't see the file when you do a normal listing.  The filename for the tcsh shell is .tcshrc (.cshrc works too), and the other shells follow the same format, shell name and rc (this stands for run command).

In this file, you want to alias "rm" to "rm -i".  You should already have a couple of alias setup anyway, so just copy the format, or you may need to search online for example for your shell.  It's assumed you know how to edit a file, if not, get a friend to help you use the vi editor.

You then want to alias RM to rm -f, this will let you remove files without prompting, if you are really sure.

Understand clobber!

Deleting a file isn't the only thing you can do, it's really easy to overwrite an existing file by using redirect.

Turn on the noclobber option particular to your shell, however it's best to just understand the difference between > and >>.

I've seen time and time again, someone wants to add some data:

cat > important.file.txt

and then the important file is suddenly much smaller.  Please remember to add anything just use >>, best yet don't even mess with > and use the "touch" command to create a file, then add using editor (cut/paste) or cat >> file.

Alias ls!

 You will probably get into the habit of listing files in directories quite often, a good default is

ls -trl

Or you can key ls -ltr, it doesn't matter what order the flags are in.

This will list in long format, and newest files at the bottom.

You may want to alias this to ll.

Use less!

 If you use text files at all, you will want to use a pager.  The typical option is:

more example.file

which will show file page by page, along with other options.

But an even better tool is less, I would alias more to less if you are used to keying more.

Please just don't do this:

cat example.file |more

you are just wasting keystrokes, but don't worry even expert users are caught keying this when it's busy.

Understand dot files!

 Make sure you experiment with using . and ..

Go deep into a directory tree,such as /usr/local/test/bla/test and key

cd ../../ and see what directory you are in "pwd".

Create a new directory in your home directory, /home/user/copy and then go to /tmp and find a small file to copy.  In your home directory /home/user/copy key cp /tmp/smallfile . and see what happens "ls -ltr".

Many users use the .. alias but not so many are using the .


Understand PATH!!

 I added an extra ! since this subject is something that will piss off any knowledgeable UNIX user who has to work with users.

Although this subject may be ahead of beginners stage, it's still explained right away in most UNIX books, but is glossed over.  Get into the habit of keying "which <command>" to see how this command is being found.

You will probably see "shell built in" if you key "which echo".  This means that this is integrated into the shell you are using (the shell itself is a program in a path).

For example you will most likely see "/usr/bin/ls" if you key "which ls".

This means when you key "ls" it is really running "/usr/bin/ls".  How does this happen?  You have this setup in your run command file in the home directory, the PATH variable is assigned some directories typically by default. Key "echo $PATH" and see what is displayed.

If you have a special directory that containes utilities you often have to use, and you spend a lot of time changing to that directory, you may consider adding this directory to PATH to save time.

Some hardcore people may even suggest that a beginner not even run any command unless it's using absolute path, so everything you run will start with root directory /.

So instead of running "echo test", you would run "/usr/bin/echo test".  This is a curious example as echo is a built in shell command, but there is also another version in /usr/bin/ typically.  Which one do you think would be more portable to use?

The stuff in the UNIX books about PATH and absolute and relative paths may be a little dry, but this is essential to visualizing things and really understanding how the programs work later on. 


 There is plenty more, but this should cover a few things I've seen over the years.

The one last thing, learn how to use man.  Key "man man".

If man pages are not installed, find a system in which they are, or complain to your System Administrator.  Most man pages are online now anyway.


    0 of 8192 characters used
    Post Comment

    No comments yet.


    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at:

    Show Details
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the or domains, for performance and efficiency reasons. (Privacy Policy)
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)