Tag Archives: bash

Fish is a friendly command line shell for Ubuntu/Linux, Mac or any other operating system from the *nix family. If you use bash (the default shell in Ubuntu) often, then you may want to give it a try. It has lots of smart features you may find productive.

Features

Autosuggestions – It suggests commands when you type, based on history and it’ll often save you some time with the commands you type more often.

Scripting – Similar to bash but the syntax is much simple, clean and consistent.

term256 – it supports 256 colors.

Sane defaults – Most of the features will work just fine without any additional configurations.

Installing Fish in Ubuntu

Fish is already there in official package repository (tested on Ubuntu 14.04 LTS). So, you can install it right away

sudo apt-get update
sudo apt-get install fish

If it’s not available in repository or you’re using other Linux distribution ? Check out official page to download a tarball for your distribution.

To start fish, simply type fish on your terminal and you’ll jump into the fish shell. Type help and it will open the documentation tab (hosted locally) in your default browser. Also read official tutorials to learn more about the features of Fish Shell.

Terminal Commands are cool and very handy sometimes (even for common users who don’t like terminal), also useful in learning some cool stuffs about Ubuntu or GNU/Linux in general (so it’s also good for learners).

I’ve prepared a list of few terminal commands – that anyone can learn and master (in couple of minutes), in order to enjoy a better experience with Ubuntu or other Linux distributions (and don’t worry about – the Ubuntu version you are using such as – 12.04 LTS – “Precise Pangolin” or 11.10 or may be the upcoming one – 12.10, because it doesn’t change often unlike the other things in Ubuntu :), same for Ubuntu derivatives such as Linux Mint 13(Maya)).

Top 17 commands for Ubuntu Beginners

Basics GNU/Linux Commands

#1. ls : list directory contents

ls

If you want to see hidden files/directories (beginning with dot.), the use -a flag.

ls -a

Check the manual for more detail (man ls).

#2. cd : Change Directory

cd ../
cd /home/Desktop

Remember,

. represents the current directory

.. represents the parent directory

~ represents the home directory (of the user)

#3. pwd : print the current/working directory

pwd
/home/Desktop/scripts

#4. mkdir : make/create directory.

mkdir funny_stuffs

#5. rm : remove/delete file/directory

rm useless.sh

NOTE : it removes directories only if it’s empty, unless you specify -f flag for force deletion. But you must be careful with the arguments such as -r, -f. (-rf is very dangerous).

#6. sudo : superuser do, to gain root privilege

e.g

sudo apt-get install gnome-shell

Then enter your user account password, and you would be able to do administrative tasks like root. So if you’re getting any permission error using a command, then adding sudo as a prefix, might help.

#7. mv : rename or move a file/directory

mv file1 ~/Downloads/Archive/

the above command will move the file from the current directory to target directory.

mv logo_2.jpg new_logo.jpg

it will rename the file to new_logo.jpg.

#8. cat : View File contents

cat install.log

#9. man : A Reference manual for utils/commands/programs

e.g if you want to know more about rm command, then type –

man rm

#10. cp : Copy Files/Directories

cp movie_name.mp4 ~/Downloads/movies/

The above command will copy the movie_name.mp4 to the specified directory.

#11. wget : Download files from server

GNU Wget or wget is very handy in downloading stuffs from internet, over the command line.

wget url_of_the_content

#12. gksudo : Run GUI Application with Root privilege

gksudo nautilus

The above command will open nautilus with root privilege. It’s just like sudo, but in GUI mode.

#13. shutdown : To shutdown the computer from terminal

shutdown -h

where time can be 0 if you want to shutdown now or specify the exact time such as 10:30.

#14. restart : Restart the computer

restart

Package Management

These are Ubuntu Specific commands. It Requires root privilege, so just add the sudo prefix before each command (it will ask for the user password and you’re done!).

#15. apt-get : Command Line Tool for handling packages
There are various options such as

In early days it was difficult to manage the permissions for different users in a multiuser operating system that may be a client or server;suppose every user has a power of a superuser or root then any one of them may be misused the system either intentionally(If the user is smart) or ignorantly(If the user is a beginner one).Hence the simple solution of this problem is to limit the power for every users according to their need so that they can do simple tasks normally but in case of any administrative task root power is granted for small period(usually five minutes)by using the sudo commands.In sudo su stands for superuser and do means do(as usual).Hence sudo is mostly used by a permitted user for taking the permission to execute some commands as a another user or superuser, according to the information specified in sudoers file.Suppose the user that is invoking a command using the sudo power, is root then there is no need to enter user password.By default authentication is required and the user password is required; the user may use the sudo power again for short period of time(5-15min).So sudo is very useful in finishing some administrative task by a simple user.Now we are going to learn something more about the sudo commands.

Syntax of the sudo commands :

It is very simple..just use the word sudo before the actual command and hit enter.Then it will ask for the users password ..enter the password after the authorization process the commands will execute.e.g I am trying to execute commands1(installing a package using apt-get).

Options in SUDO :

-A: Using this option the another helper program(It may be in graphical format) is called and executed to read the password of the user and output the user password to the canonical output.

-u user : this option tells the sudo to run the target command as a user instead of root(which is default case).You may use UID rather than username by using UID followed by ‘#’.i.e #uid.-a : It is used by the sudo to use the special authentication type for the validation of the user according to the permission settings stored in /etc/login.conf.
This option is is used only in the system having the support with BSD authentication mechanism.

-b : Specifying -b(background) with the sudo command simply means to order the sudo that “run the target command in background”.

-p prompt : By using -p (prompt) one can easily customize the password prompt.So using some ‘%’ escapes(e.g %H,%h,%p) you may use any other prompt rather then the default one.

Although there are many other options available but you can easily find out in your bash shell.just type info sudo and hit enter.

Environment Variables :

here are the some environment variables used by the sudo.

USER : Set to the current user.By default its value is equal to root if -u option is not specified.

SUDO_UID : user ID of the user who used the sudo.

SUDO_USER : Set to the login of the permitted user who is using sudo.
Go to your bash terminal for the details about the more environmental variables(info sudo OR man -k sudo OR help sudo).