Basic Terminal Commands | openGLUG


Saturday, 1 June 2013

Basic Terminal Commands

Today i am going to show some of basic terminal commands for doing some basic tasks.

Creating Files:

The 'touch' utility sets the modification and access times to the current time of day. If the file doesn't exist, it is created with the default permissions and attributes.

touch /path/filename

    Above command will create an empty text formatted file in the path and filename provided. If a file with same name already exist, that file will be overwrittenand all it's contents will be lost.
To prevent this following command can be used.

touch /path/filename >> /path/filename

The above command will only alter the the modification date and time settings if the file specified is already exist. Otherwise a new empty file will be created.

Creating Folders/Directories: 

For creating Folders, command 'mkdir' can be used. The general syntax is as below.
mkdir /path/folder_name/

If the command provided only with the directory name without the path, then a directory with the given name will be created in the current directory.

Copying Files/Folders:

'cp' is the command for copying Files and Folders. The general command given below can be used to copy files by replacing the source and destination.

cp /source_file /destination_file

Note: In order to copy directories, '-r' should be used which copies a directory along with it's subdirectories also. i.e., '-r' invokes the recursive copying process.

Removing Files/Folders :

'rm' is the command to remove Files/Folders in UNIX like systems (at-least in Ubuntu). To remove a file located at 'path' use the following command.

rm path/file_name
Note: Use -r if you want to delete a directory tree as you do while copying files and subdirectories of a folder. Here also '-r' invokes recursive execution of 'rm' command for all contents of the parent directory supplied as the path argument.  

Installing Packages:

Installalling packages in Ubuntu is very easy with  "apt-get" and "dpkg" commands. "apt-get" can be used to download and install softwares.
==> If you have already downloaded the debian(*.deb) packages and want to install it then you can use command 'dpkg' as

sudo dpkg -i package_name 
  sudo - Gives Super User or root permissions for the command 'dpkg'
  dpkg - Debian Package Manager
  -i   - Instructs the 'dpkg' to install the specified package
  package_name - Path to your downloaded *.deb package file.

==> If you don't have the software package you want to install then you can use 'apt-get' command to download and install the package from the Ubuntu repositories.
sudo apt-get install package_name

  sudoGives Super User or root permissions for the command 'apt-get'
  apt-get - A simple command line interface for downloading and
installing packages.
  install - Option to instruct the 'apt-get' util to install the downloaded package.
  package_name - Name of the package that you want to download and install from the Ubuntu repositories.

Note:- The package name for apt-get command should be exactly as in the repositories. Otherwise apt-get command will fail with errors.


1 comment:

  1. I am very happy to read this post and enjoying this Post. Really it is very helpful to me.

    Concrete Gold Coast