Linux

How To Set Your Linux Command Shell

Linux Shell

One of the best things about the Linux command line is the ability to recall the last used command by hitting the up arrow ↑. Yes, I realize that Windows command line has done that for a long time, but where do you think they got the idea for that?

I’m fairly new to this whole Linux thing and I had an issue where I used SSH to get to a Linux server but when I ran a command and then hit the up arrow ↑, I got back a couple unreadable characters instead of the previous command. I found out that I was using the wrong command shell for what I was wanting to do.

There are a few shells that seem to be fairly common:

  • bash – Bourne again shell
  • ksh – Korn shell
  • csh – C Shell
  • dash – Debian almquist shell

I’m not sure which shell I was using that day, but I figured out that I needed the bash shell. Below are a few commands that will help you when working with your command shell:

  • To find all of the available shells in your system, type the following command:
    cat /etc/shells
  • To find out your current shell, type any of the following commands:
    echo $SHELL
    ps $$
    ps -p $$
  • To change your shell to the bash shell, type the following command:
    chsh -s /bin/bash

Anything else you want to add to the discussion about shells?

 

How To Find Basic Linux Hardware Info

You can use the below to find some basic information about the hardware your Linux system is installed on:

How much RAM is installed and how much of it is in use (megabytes).
 It will also include swap memory:
  $ free -m
 total used free shared buffers cached
Mem: 3949 3189 760 0 599 1594
-/+ buffers/cache: 995 2954
Swap: 16386 109 16277

Processor type:
  $ cat /proc/cpuinfo

Check the size of the hard drive and what hard drives are available in the system.
 This command will also list USB drives and sticks. You need root permissions to execute the fdisk command:
  $ sudo fdisk -l | grep GB
Disk /dev/sda: 42.9 GB, 42949672960 bytes
Disk /dev/sdb: 107.3 GB, 107374182400 bytes

Got any other tips for me?

How To Find Your Linux Version

I’ve been doing a few things in Linux lately and needed a couple things like: What version of Linux am I using?

$ lsb_release -a
LSB Version: :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: EnterpriseEnterpriseServer
Description: Enterprise Linux Enterprise Linux Server release 5.5 (Carthage)
Release: 5.5
Codename: Carthage

This Linux stuff is a little new for me, so hope that helps someone else out there.