Command Line Package Management [Debian Based]

you can use ‘apt-get’ tool to manage packages via the CLI instead of using the GUI. ‘apt-get’ can be used to install and uninstall packages as we needed. For your convenience Im going to introduce another CLI tool , ‘dpkg’. Most of you may already have useded it.

Installing a program:

apt-get install

apt-get install

system will check the repositories and install it into the pc from a desired place. By default it will connect your PC to a FTP server and download the required package and its dependencies, then install. This method is highly effective for a good installation.

If you want to install a package which is already saved in your pc,

dpkg -i

dpkg -i

At times you have to download the package source code/binaries and compile it then install. To do that go in to that folder and follow the following steps,

#./configure
#make
#make install

Uninstalling a program:

same tools again!

dpkg --list

dpkg --list

using the above code you can get a list of installed programs.You can use ‘apt-get’ as shown bellow to remove programs,

apt-get remove

apt-get remove

when after performing an ‘apt-get install’, by experience you ll understand that its installing  also other packages as dependencies. We can also remove a program with all its dependencies.

apt-get --purge

apt-get --purge

these are the basics of Linux file management via CLI. Feel free to experiment the commands and rediscover the CLI.
……………..enjoy…………….

Advertisements

Formating Pens & Other External Storage Media in GNU/Linux.

I thought to write this post in a hurry. Because I realized this topic is a common question among New GNU/Linux users and who converted to Linux from windows. Ya its reasonable for windows guys because they perform that task so easily just, right clicking on the device. Its cheap huh?

            I can see my 1GB good old pen is resting on my front USB port!Sorry Pen your going to get formatted. Please make sure, you have selected the correct device by running fdisk -l (I have don this before in detail. New readers, please check my ‘awesome CLI‘ posts.) in your terminal/konsole. mm.. well mine is /dev/sda1 .

            Now get into root mode by giving su or sudo su. Then follow my example. And make sure the device is not mounted.

mkfs.vfat /dev/sda1

mkfs.vfat /dev/sda1

I have turned my good old pen into a FAT file system. File system depends on users choice. If I want it in ext3 Itl appear like this,

mkfs.ext3 /dev/sda1 

This is how we does. This is how GNU/Linux does. Smart huh!

Partitioning in Linux [cfdisk]

Hi Fellows! My OS[Linux Mint] is near to crash because of my endless, inappropriate experiments. But what to do, My endless curiosity doesn’t leave My OS  alone.

            In this post I m going to demonstrate how to partition a Hard Disk/Flash Drive without any extra tools. All you have to do is to enter some commands in CLI. I’m using My 1GB small old pen drive. And please make sure that you have chose the correct device. Else I don’t have to say what would happen!

            Open the terminal/konsole, then identify your device by giving,

fdisk -l             (I have done this in an early time in detail)

            My device is /dev/sda1.

cfdisk /dev/sda1 (cfdisk is the Curses based disk partition table manipulator for Linux)

then you l end with something like this,

fdisk /dev/sda1

cfdisk /dev/sda1

 In My example I m creating 2 partitions. And one of them is a swap area. Navigate to  New using arrow keys. Press enter. you l end up with the following result,

step2

Creating a New Primary partition

 

 Press Enter.  Then give the Partition size you want.

assigning the size

Assigning The Partition Size

I gave 800MB for My 1st partition. Press Enter.

add partition at beginning of free space

Add Partition at Beginning of Free Space

Select Beginning. It will create the partition at the beginning. Or if you want it at the end select End.As I done the fist partition(sda1p1), I have created another partition named sda1p2.

created two partitions

Two Partitions are Created

With the arrow keys navigate to Type. Then press Enter.

selecting a file system

Selecting a File System

 

 Check this out. you get a big list with a variety of file systems. I want mine as Linux Extended. I went step forward by pressing a key. Then gave the corresponding number for Linux Extended.

entering the filr system type

Entering The Filr System Type

 

 Following the same steps, I set the other partition’s file system as swap. Finally select Write and press Enter.

write partition table to disk
Write Partition Table to Disk

Its good to go! We are done with partitioning. 

…….Later……

 

 

Awesome to work in CLI [Not for Masters but for Beginners] – Part III

Hope my last two post gave some basics of Linux/CLI for your knowledge. From Part III I m l trying to demonstrate some file operations which is very common in CLI, stuff like making new directories/files, coping, moving and removing . Lets hit it from level 0. So fire up your Terminal/Konsole & start working with me.

Lets start by making a new directory named D1.

 

Making a New Directory

Making a New Directory

 

You must be familiar with ‘mkdir’ because we have used it before. In a moment when we have to create more than one directory, its not a must to create them one by one. See the example.

Making More Than One Directory

Making More Than One Directory

I have created 3 more new folders/directories namely D2,D3 and D4 just entering a single command. Like that you can add more arguments with mkdir. It saves lot of time.

             Now try to make changes in our newly made directories. Its not working huh? it happens because of its default permission pattern. Check it out by giving ls -l. Now  I m assigning full rights to all, by giving 777 with chmod (chmod 777 directory_name  see cli-partI for help) for my convenience. Now I m creating another directory named as D5 and configure its permission to 777. But in a single step,

 

Creating ang Changing Permision

Creating ang Changing Permision

See, I didnt use chmod command. -m is to set the permission mode.    

Now I need another directory D6, with a subdirectory named sub1. this is how  I m making it,

Creating Subdirectories

Creating Subdirectories

Tryout this with -m argument.

Ok, now its time to make files. You can use touch command for this purpose. touch command enables the user to change access, modification time for a given file and create files. Here, I m creating files inside of D1 directory.

 

touch

touch

I have created 5 different files with different extensions. use stat command to get more info about a specific file.

stat

stat

Notice the Access time. I can change it to my present time with -a argument.

-a argument

-a argument

Like that I can also change the Modify time to my present time with -m argument.

-m argument

-m argument

 

User can also assign date/time for his/her request. I m changing the date into 2009/jan/15 and time into 12.48.10. Here we go,

 

Changing Date/Time for User Request

Changing Date/Time for User Request

 

 

Coping is another file operation. In CLI cp is used for this. cp can be used with many arguments and it can be done in many ways . Here I m coping D1 and its content into D2,

cp

cp

Now I m coping only the content of D1 into D3,

Coping Only the Content

Coping Only the Content

And watch this,

-i with cp

-i with cp

-i prompt you before overwriting a file    

This is not all with cp command. It can work with many other arguments.

Moving is another important file operation. You can perform it in the same way we  copied files and directories. But you have to give mv command instead of giving cp.  mv is also used to rename files and directories.

Renaming a File/Directories

Renaming a File/Directories

In the above example, I have renamed directory D5 as D10.

rm command is to remove files and directories. Usually this 1st example is called as ‘interactive Remove’.

 

Removing Files

Removing Files

Above, I have entered into D1 directory. Then removed the file named ‘file2.odt’. Here, its important to using -i argument because it prompt the user before deleting any files or directories. You can also force to delete write protected files by giving the -f argument instead of giving -i.   

Notice: Be careful with using rm command because it can destroy your important data.   

use -fr argument with rm command to delete/remove directories.

Removing Directories

Removing Directories

I have delete ‘D4’ by following the above method.

This post is getting longer and longer. So I should stop from here. I ll give you more awesome CLI tips from another post, Remember this Blog is dedicated to GNU/Linux beginners. So stick with dushan888.wordpress.com.

 

 ……….Later……….

 

 

Awesome to work in CLI [Not for Masters but for Beginners] – PartII

Hope you enjoyed my last CLI post. I told you its Cool! Today you will able to mount your devices/file systems using the CLI . Yes there are lot of things to learn before this, but I think this will be more helpful for you’r day to day work. Sometimes devises/file systems will not be mounted automatically (most of the time it happens on newly attached hard drives in NTFS or FAT32 format and when the partition table entries are not in disk order. But there can be more other reasons for this). You may have experienced this already. So in this case  you need the command line to mount them manually.

            Before mounting you should identify the partitions correctly. So fire up your terminal/konsole (I use Yakuake) give this command,

fdisk –l           

            When using this command, You should first have to be ‘root’ to get information about the internal hard drivers(internal file systems). If not you can only get info about external media/USB devices, if you have plugged any. So type,

su or sudo su and press enter. then give the root password to get root privileges. then give fdisk -l. Now you l get what you want.

This is a part of my result (which gives me troubles),

fdisk -l

fdisk -l

 I want to mount ‘hdd5’. I give this commands to do this,

mkdir /mnt/hdd5        

mount -t ntfs /dev/hdd5 /mnt/hdd5    

            Great! Now I have mount the partition I wanted. ‘mkdir‘ is to make a directory. Here I made a directory named ‘hdd5’, inside the ‘mnt’ directory. ‘mnt’ directory works as a mount point for a temporarily mounted file system. The 2nd command describes the following things,

mount -t ntfs /dev/hdd5 /mnt/hdd5

mount -t ntfs /dev/hdd5 /mnt/hdd5

User can remount his/her partitions with assigning permission types. I m going to remount my ‘hdd5’ with ‘read only’ permission.

Remount with Read only

Remount with Read only

 

I cant stop  only reading it, I want to write on it!

 

 

 

Mount with Read Write

Mount with Read Write

 

 This is all to teach about Mounting! No big deal huh? Keep learning Linux/CLI with Dushi.

 

 

                                                                ……………Later………..

 

 

 

 

%d bloggers like this: