Showing posts with label pwd. Show all posts
Showing posts with label pwd. Show all posts

Wednesday, October 17, 2012

Twelfth session of Some of basic UNIX commands that are useful very frequently


Today we will discuss about some more commands that are used very frequently in UNIX/LINUX based systems.

echo is a command used to print any argument that we give. Basically this command is very useful when one want to write shell script(.sh) like batch script(.bat) that we used to write in Windows based systems.

echo argument

Above command will display 'argument' in the terminal. So, while writing shell script and want to debug/log user given argument then, we use this. Its similar to 'System.out.println' that we use in Java to print some thing.

file is a command used to determine type of file by examining its content.

file .bash_profile

Above command will display classification of file named '.bash_profile' present in home directory i.e. /home/ by examining its content. Below is its output:

$ file .bash_profile
.bash_profile: ASCII text


head is a command used to display first few lines of file specified as an argument.

head filename

Above command will display first few lines of a file named 'filename' present in current working directory. Below is output of head command executed on file named 'terimerilyrics':

$ head terimerisonglyrics
Aa......

Teri meri, meri teri prem kahani hai mushqil
Do lafzoon mein yeh bayaan na ho paaye
Ik ladka ik ladki ki yeh kahani hai nayi
Do lafzoon mein yeh bayaan na ho paaye

Teri meri, meri teri prem kahani hai mushqil
Do lafzon mein yeh bayaan na ho paaye
Ik dooje se huey juda Jab ik dooje ke liye bane


As conveyed in previous posts, don't hesitate to try these commands. We will discuss about some more useful commands in next posts.

Tuesday, October 16, 2012

Eleventh session of Some of basic UNIX commands that are useful very frequently


Today we will discuss about some more useful commands that are frequently used in UNIX/LINUX based systems.

wc is a command by which one can know about no of lines, words and characters present in a file.

wc filename

Above command will gives number of lines, words and characters present in file named 'filename' present in current working directory. You can know current working directory by using pwd that we discussed in previous posts.

date is a command which displays current date and time.

diff is a command using which you can find differences between two files. It displays differences between two files by comparing each other.

diff filename1 filename2

Above command will show all differences between files named 'filename1 and filename2'present in current working directory.

du is a command by which one can know disk usage i.e. space used by directory and its contents.

Don't hesitate to try these when you are free. If you already got a chance to try these, feel free to give your valuable feedback/comments. We will discuss about some more useful commands in next posts.

Tuesday, September 25, 2012

Eighth session of Some of basic UNIX commands that are useful very frequently


Today we will discuss about some more useful commands in UNIX/LINUX based operating system.

If you want to see quickly what is the content of a file, then you can use below command to see the content of file in the same terminal you are working currently.

cat filename

Above command will display content of file named 'filename' present in current working directory in the terminal.

cat filename > /x/y.txt

Above command will copies content of file named 'filename' present in current working directory into file named 'y.txt' present in path '/x'.

cat filename1 filename2 > /x/y.txt

Above command will concatenate content of files named 'filename1'and 'filename2' present in current working directory into file named 'y.txt' present in path '/x'.

cat filename1 filename2

Above command will concatenate content of files and displays in the terminal. It doesn't modify original files instead it display both files content into terminal by concatenating.

One more important command that we are going to discuss today is 'ps'.

ps

Above command will display current processes which are running. This command is some what like a 'Task Manager' in windows where as the difference is in task manager we can kill process which we don't want to run but, here we can know process IDs by which we can delete the process using 'kill' command that we can discuss in our next post. This command will display lot of information about processes that are currently running.

ps -u

Above command will display current processes that are running in current log-in.

Please feel free to post your comments/queries. We can discuss some more useful UNIX/LINUX commands in our next post.

Monday, September 17, 2012

Sixth session of Some of basic UNIX commands that are useful very frequently


Today we will discuss about some more useful commands that are used very frequently when you work with UNIX/LINUX based Operating Systems.

mkdir is a command which created new directory in your file system.

mkdir NewDirectory

Above command will create new folder named 'NewDirectory' in present working directory. You can fetch your present working directory by hitting 'pwd' in your terminal. For suppose you are in directory '/home/x/y' then new directory named 'NewDirectory' will be created in ' /home/x/y'.

mkdir /x/y/z NewDirecotory

Above command will create new folder named 'NewDirecotry' in the path '/x/y/z'.

Similarly you can remove a folder and its contents by using command rmdir.

rmdir NewDirectory

Above command will deletes/removes a folder named 'NewDirectory' from current working directory. If that directory contains any sub folders/files then will confirm from user before deleting each file/folder with 'Y/N ?'. So, you can remove/delete each file/folder by pressing 'y'.

rmdir -f NewDirectory

Above command will deletes/removes 'NewDirectory' and its contents without asking confirmation to delete.

rmdir -f /home/x/y/*

Above command will deletes/removes content (files/sub folders) in the path '/home/x/y' without asking confirmation to delete. Like '*', we can use patterns to delete files. Below is small example:

rmdir -f /home/x/y/a*.java

Above command will deletes/removes files whose names starts with 'a' and extension '.java' in the path '/home/x/y/'.

Don't hesitate to try these when you are free.. If you already had a chance to try these, then don't hesitate to write your valuable comments. Will discuss some more in next post....

Friday, December 23, 2011

Second session of Some of basic UNIX commands that are useful very frequently


Hi Folks,

In this i want to share some other UNIX/LINUX command which is useful for us very frequently.

To display list of files,directories that are available in current directly please run below command.

'ls'

If you want to see more options that are available for this command then you can run below command

ls -a - This option is used to display hidden files along with normal files.

ls -l - This option displays full details of all files and folders present in current directory. For example see below sample output of this command.

drwxr-xr-x 2 user group 4096 2011-01-06 12:06 Public
In this output, highlighted part consists total 10 fields which includes of below information:
d - means its a directory.(If it is file then this will be blank).
r - read permission for user,group,others.
w - write permission for user,group,others.
x - execute permission for user,group,others.
So, first 'rwx' means this file has all permissions for user. Next 'r-x' means this file has only read and execute permissions for group. Next 'r-x' means this file has only read and execute permissions for others.

ls -d */ - This option shows only folders present in current directory.

ls -s - This option shows files and folders present in current directory along with their sizes in blocks.

ls -lt - This option shows files in the order of their last modified time.

pwd - This option shows present working directory.

Please try these when you are free. In our next session we can discuss some other commands.