basic linux

Taking care of your Linux box.

basic linux

Postby hameedkhan » Thu May 13, 2004 12:30 am

hi,
how are you all? i want to ask few basic questions about linux. questions in list form are as follows:

1) how can one set and unset environment variables? i know export tried to read its manual page but didn't undertand anything from there may be because i was in hurry. i'll try to the the man page for it again. but is there any other command for setting and unsetting environment variables directly from the command line.

2) how can we directly calculate something on the command line? like if i want to calculate 2+2 how can i directly calculate it on command line i tried echo 2+2 but didn't work. is there any way we can do it.

3) what are hardlinks? i know symlinks they are only refrence to the actual file. but i didn't understand the hardlinks concept from the man pages.


thanks in advance ;)
Hameed Khan
hameedkhan
Havaldaar
 
Posts: 141
Joined: Wed Apr 07, 2004 12:58 am
Location: Karachi, Pakistan

Postby farhantoqeer » Thu May 13, 2004 9:10 am

1) export NAME=hameedkhan

2) echo 2 + 2 + bc

3) hard link is another name of an existing file thie link and the original are indistinguishable.
info ln
A: Yes
Q: Is top-posting bad?
farhantoqeer
Major General
 
Posts: 917
Joined: Thu Jun 27, 2002 5:45 pm
Website: http://www.emergen.biz
Location: Karachi

Re: basic linux

Postby fawad » Fri May 14, 2004 1:07 am

hameedkhan wrote: 1) how can one set and unset environment variables?

Previous post mentioned setting envvars. To unset just type
unset ENVIRONMENTVARIABLE

hameedkhan wrote: 2) how can we directly calculate something on the command line? like if i want to calculate 2+2 how can i directly calculate it on command line i tried echo 2+2 but didn't work. is there any way we can do it.

A billion different ways:
perl -e "print 2+2"
python -c "print 2+2"
dc -e "2 2 + n"
hameedkhan wrote: 3) what are hardlinks? i know symlinks they are only refrence to the actual file. but i didn't understand the hardlinks concept from the man pages.

hardlinks make the file point to the actual inode for the file. i.e. it becomes a reference to the filesystem. Try this as an experiment (lines starting with $ are the commands to type).

Code: Select all

$ touch foo
$ ls -li foo
32017 -rw-rw-r--  1 fawad fawad 0 May 13 15:00 foo
$ ln -s foo bar
$ ls -li bar
33301 lrwxrwxrwx  1 fawad fawad 3 May 13 15:01 bar -> foo
$ ln foo baz
$ ls -li baz
32017 -rw-rw-r--  2 fawad fawad 0 May 13 15:00 baz
$ rm foo
$ cat bar
cat: bar: No such file or directory
$ cat baz
<BLANK LINE>


Notice that the inode # for both foo and baz are the same, while that for bar (the symlink) is different. Also, when we deleted foo, bar became an invalid symlink because it was pointing to the file 'foo'. However, baz is still there because it was pointing to the inode, not the filename.

Hope that clears it up.
fawad
Site Admin
 
Posts: 918
Joined: Wed Aug 07, 2002 8:00 pm
ICQ: 17672437
Website: http://www.fawad.net
WLM: fawadhalim@hotmail.com
Yahoo Messenger: fawad2048
AOL: fawadhalim
Location: Addison, IL

Postby hameedkhan » Fri May 14, 2004 11:25 am

hi,
thanks fawad and farhan. fawad i know the ways to calculate you tell me but i was asking if there is any shell builin way. like if we just type "2+2" with or without quotes at command line and then hit enter and the shell give us results. but i think that there is no such way. maybe in future version they will include that. anyways, thanks to both of you for helping me.

Thanks,
Hameed Khan.
Love Pakistan or Leave Pakistan.
hameedkhan
Havaldaar
 
Posts: 141
Joined: Wed Apr 07, 2004 12:58 am
Location: Karachi, Pakistan

Postby farhantoqeer » Fri May 14, 2004 2:37 pm

you can get the result at shell, i miss typed it was

alien$ echo 2 + 2 | bc
A: Yes

Q: Is top-posting bad?
farhantoqeer
Major General
 
Posts: 917
Joined: Thu Jun 27, 2002 5:45 pm
Website: http://www.emergen.biz
Location: Karachi


Return to “%s” Administration

Who is online

Users browsing this forum: No registered users and 1 guest

cron