My First Post      My Facebook Profile      My MeOnShow Profile      W3LC Facebook Page      Learners Consortium Group      Job Portal      Shopping @Yeyhi.com

Pages










Showing posts with label unix. Show all posts
Showing posts with label unix. Show all posts

Saturday, January 14, 2023

Few Jokes on Unix Operating System and its functionalities *

I remember i wrote a joke on UNIX users a few years back in one of the blog. I was also sharing this with my colleagues in different offices i worked in. Few friends back there in Adobe system and Symantec used to love these kind of jokes. So i thought few more jokes that i have invented (or discovered or written ☺) since then.


The first one is:

Question - Why did the man using UNIX spend all day at the terminal?

Answer - Because he couldn't figure out how to use the "vi" command to exit!

This was a joke because of similar sound of bye and vi especially in some parts of the world.


Question - Why did the man using UNIX always wear sunglasses?

Answer - Because he was always 'ls'-ing in the sun!

Now this used the similarity between the word 'lying' and 'lsing'


Question - Why did the UNIX user wear a tie to the beach?

Answer - Because he wanted to be "root" in the office and "user" at the beach.


Question  - Why did the UNIX user put his computer in the freezer?

Answer - Because he wanted to "cool down" his "system".


Question  - Why did the UNIX user stare at the black screen for hours?

Answer - Because he was trying to "cat" the manual!


Please note that these are just jokes and should not be taken seriously. Unix users are just like any other group of people and should not be stereotyped or discriminated against based on their profession or preferences.

PS: The first of my such joke appeared here in 2013 - https://www.w3lc.com/2013/05/checking-file-system-directory-size-in.html



Friday, July 10, 2020

CSV delimiter linux Vs Mac : Resolving the issue of comma separated file read and write

Excel allows CSV that is Comma Separated Values in its filesystem. It uses comma as a delimiter.
And, this format is often used for exchanging data between programs. But there comes issues while working on different operating systems.


As per my research, there could be three versions of CSV formats included with Excel:


  • CSV (Comma delimited) (*.csv)
  • CSV (Macintosh) (*.csv)
  • CSV (MS-DOS) (*.csv)
The main difference arises because on a Macintosh each record (each line in the file) is terminated with a carriage return, as expected by the Mac. In the Windows, lines are terminated with a carriage return and line feed combination (CRLF). This can mess things up on the Macintosh.


Example suppose you are using Python for CSV Reader or writer mechanism then you should take care of two points:

1. use wb mode in file processing.

https://docs.python.org/2/library/csv.html#csv.writer


If csvfile is a file object, it must be opened with the ‘b’ flag on platforms where that makes a difference.

That is,  where you are writing file, open in binary format - wb mode
And, when reading - use rb mode

2. Use proper line separator. Better to use os.linesep



Even in viewing file also, you can do the difference if it is only a one time change:


Open your csv file with WPS Spreadsheets

Select the A column -> Data -> Text to Columns -> Next -> Select or define your delimiter -> Finish


You can also view a related post:

Cheers ;)

By the way I quit smoking. Did you know?

Monday, May 4, 2020

Simple Ways to Get the Size of Directories and files in Linux


  • Check Disk Space with the Commands du and df - Linux
  • How to find size of directory in linux
  • How do I get the size of a directory on the command line
  • Linux Check Disk Space Command To View System
  • display the size and other stats of a file/directory or a filesystem.
  • How to Get the Size of a Directory in Linux | Linuxizelinuxize.com › post › system Linux and Unix du command tutorial with examples


To answer these questions, I published an article in 2013. Since then it attained nearly half a million views. After 7 years, i find myself prompted to add some more details on it in relation to latest developments around this. So, please have all your above answers here:


Linux (and Typically all UNIX based or UNIX alike systems including AIX, Solaris, MAC or CentOS) offer two commands for checking out free disk space.


1. Linux "df" command :

Report file system disk space usage. That is, it shows information about the file system on which each FILE resides, or all file systems by default.


Syntax:  df [OPTION]... [FILE]...

Mandatory arguments to long options are mandatory for short options too.

  -a, --all             include dummy file systems
  -B, --block-size=SIZE  use SIZE-byte blocks
  -h, --human-readable  print sizes in human readable format (e.g., 1K 234M 2G)
  -H, --si              likewise, but use powers of 1000 not 1024
  -i, --inodes          list inode information instead of block usage
  -k                    like --block-size=1K
  -l, --local           limit listing to local file systems
      --no-sync         do not invoke sync before getting usage info (default)
  -P, --portability     use the POSIX output format
      --sync            invoke sync before getting usage info
  -t, --type=TYPE       limit listing to file systems of type TYPE
  -T, --print-type      print file system type
  -x, --exclude-type=TYPE   limit listing to file systems not of type TYPE
  -v                    (ignored)
      --help     display this help and exit
      --version  output version information and exit
SIZE may be (or may be an integer optionally followed by) one of following:
kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.

EG. I am in a directory. But "df" command has nothing to deal with that. It outputs current OVERALL status of the system and its partitions.


 



2. Linux "du" command :


Estimate file space usage. That is, it summarize disk usage of each FILE, recursively for directories.


Syntax: du [OPTION]... [FILE]...

Mandatory arguments to long options are mandatory for short options too.

  -a, --all             write counts for all files, not just directories
--apparent-size   print apparent sizes, rather than disk usage; although
                          the apparent size is usually smaller, it may be
                          larger due to holes in (`sparse') files, internal
                          fragmentation, indirect blocks, and the like
  -B, --block-size=SIZE  use SIZE-byte blocks
  -b, --bytes           equivalent to `--apparent-size --block-size=1'
  -c, --total           produce a grand total
  -D, --dereference-args  dereference only symlinks that are listed on the
                          command line
      --files0-from=F   summarize disk usage of the NUL-terminated file
                          names specified in file F
  -H                    like --si, but also evokes a warning; will soon
                          change to be equivalent to --dereference-args (-D)
  -h, --human-readable  print sizes in human readable format (e.g., 1K 234M 2G)
      --si              like -h, but use powers of 1000 not 1024
  -k                    like --block-size=1K
  -l, --count-links     count sizes many times if hard linked
  -m                    like --block-size=1M
  -L, --dereference     dereference all symbolic links
  -P, --no-dereference  don't follow any symbolic links (this is the default)
  -0, --null            end each output line with 0 byte rather than newline
  -S, --separate-dirs   do not include size of subdirectories
  -s, --summarize       display only a total for each argument
  -x, --one-file-system  skip directories on different file systems
  -X FILE, --exclude-from=FILE  Exclude files that match any pattern in FILE.
      --exclude=PATTERN  Exclude files that match PATTERN.
      --max-depth=N     print the total for a directory (or file, with --all)
                          only if it is N or fewer levels below the command
                          line argument;  --max-depth=0 is the same as
                          --summarize
      --time            show time of the last modification of any file in the
                          directory, or any of its subdirectories
      --time=WORD       show time as WORD instead of modification time:
                          atime, access, use, ctime or status
      --time-style=STYLE  show times using style STYLE:
                          full-iso, long-iso, iso, +FORMAT
                          FORMAT is interpreted like `date'
      --help     display this help and exit
      --version  output version information and exit

SIZE may be (or may be an integer optionally followed by) one of following:
kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.


Eg. I am in a directory. The "du" command tells about that directory. For eg. the following picture directly outputs the total size of that folder.




Just to add more:


Remember 3 important commands when you are sitting on a linux, solaris, AIX, FreeBSD, or Mac Box [Huh, enuff. Just remember Unix :)  ]


1. df

df command can get how much space is occupied and  how much available space.

You can give a device or mount point as an argument, and df report data only for the filesystem physically residing on that device. For example, the following command provides information only for the partition /dev/sda:
$ df /dev/sda
$ df -h /dev/sdc1
$ df /data/


2. du

du is the abbreviation of “disk usage”, this command will progressively into each subdirectory


Also, we can use the du command to look at the file size:

du anwar.txt
Remember, when du reports file sizes in blocks, the size it uses depends on several factors. You can specify which block size it should use on the command line. If you don’t force du to use a particular block size, it follows a set of rules to decide which one to use.

First, it checks the following environment variables:

DU_BLOCK_SIZE
BLOCK_SIZE
BLOCKSIZE
If any of these exist, the block size is set, and du stops checking. If none are set, du defaults to a block size of 1,024 bytes. Unless, that is, an environment variable called POSIXLY_CORRECT is set. If that’s the case, du defaults to a block size of 512 bytes.

So, how do we find out which one is in use? You can check each environment variable to work it out, but there’s a quicker way. Let’s compare the results to the block size the file system uses instead.

To discover the block size the file system uses, we’ll use the tune2fs program. We’ll then use the -l option, pipe the output through grep, and then print lines that contain the word “Block.”

In this example, we’ll look at the file system on the first partition of the first hard drive, sda1, and we’ll need to use sudo:

sudo tune2fs -l /dev/sda1 | grep Block


3. fdisk

fdisk can be used to  manage disk partitions. One can do tasks like create new partition or delete an existing partition



There is yet another tool/ command that you can use:

btrfs fi df /device/ – Show disk space usage information for a btrfs based mount point/file system.



Hope this acts like a quick guide to men and women trying to play with Linux and other UNIX alike systems.

Original post link: https://www.w3lc.com/2013/05/checking-file-system-directory-size-in.html

Cheers :)


Thursday, December 15, 2016

Little 'r' me - Meaning and origin of this in email

Very often in our corporate mail boxes we get to see where members of a large email distribution ask to Little 'r' them.
This simply means to reply to them.

Advantage:
1. Reply goes only to the sender and replies do not become a spam to all in the mailing list
2. The sender can discuss some personal aspects also individually with the recipient.

Now, another question is from where did this term come from. And, it is basically this point which is interesting that how did it gain such widespread adoption.

Here are two possible reasons that convince me th emost:

Thought A:

It comes from early UNIX Email systems. From the early days of the The Internet, we used single-letter commands. The lower-case, or little, "r" command meant to reply
 to the sender. Alternatively, the capital "R" meant to reply to the sender and the other recipients.

It is this huge love with UNIX, this term has not been forgotten in the evolution of the Internet. It was hence carried forward by lots of UNIX geeks into a common internet slang.


Thought B:

Gmail has also been around now for more than a decade now. And, habits of Gmail can also be one of the reason for the evolution of this internet term.
Actually, if you want to reply just to the sender in Gmail, you just need to hit 'r'. And, if you want to reply all then you needed to hit 'a'. So, here again the term Little 'r' fits the bill.

Now, before ending let me again remember it for you - You can Little 'r' me at Toughjamy@Yahoo.com.

Wednesday, September 12, 2012

Nohup for *SO* and her Achievements


Hi,

This post is dedicated to my friend and welwisher forever. This soul has been created by God for me, I believe. She is my best friend ever, and the sources of inspiration of many of my writings. Many of my poetry work are created encompassing her at the center of my imaginations. You may call it my amitivity to maintain this inclination for her when I proclaim that had it not been for her, the best of my work would have never been produced. In fact, this blog has also been started as a dedication to her.

Many of my posts already have her name. My friend, My mate, my wife - *SO*. My readers know her very well, because of the inclusion of this name, here and there in my articles. Such is her power to affect me and my writings. And why shouldn't be it that way. After all, she owns a majestic personality with unarguably the most enchantic voice and the most refined beauties.

Apart from being the heroine (and, the only one) in all my works, she herself had been a student of computer science and holds an MBA degree. *SO* has been part of the student delegation from India to the International ABSA summit at Johannesberg, South Africa, 2009.
You can see: http://twocircles.net/2009oct13/jamia_millia_students_attend_global_student_summit_south_africa.html for the details

The IBSA dialogue forum was institutionalised in 2003, when the Head of States of the three countries signed an agreement to cooperate with each other, specifically in the fields of trade, agriculture, science and technology, health, energy and education. The IBSA Dialogue Forum presents the international community a model for further south-south cooperation, and is largely a response to previous imbalances within the international system under traditional north-south relations.

The Model IBSA Youth Summit aims to simulate the trilateral negotiation process as closely as possible while determined to reach innovative resolutions to global challenges. The Youth Summit seeks to increase awareness of the importance of the IBSA Dialogue Forum and promote an environment where students from different backgrounds can discuss and agree on solutions to urgent global issues.

The purpose of the Plenary on 24-26 September 2009, at the University of the Witwatersrand, Johannesburg , South Africa , was to inaugurate the Model IBSA Summit and plan for the Youth Summit in South Africa in 2010, and to devise a strategy for the engagement and inclusion of young people in the IBSA programme. The Summit was a three day event that consisted of an opening ceremony on the evening of the 24th, followed by two days of discussions on the main issues that were discussed under the theme: The Future of South-South Cooperation: Voices from the Next Generation.


As indicated by the following website links, it will be clearly obvious that the achievement by this young team of three, from Jamia Millia Islamia University, New Delhi, is a big one. I am elated to have met all the three members of this team, and personally knowing one in such proximity. I salute her and the team for glorifying the name of JMI, Okhla, Delhi. She belongs to cities Mathura and Aligarh of Uttar Pradesh, which in all sense should be proud of her achievements.

Click following for details:-
1. Article from Official Jamia Millia University website: http://old.jmi.ac.in/2000/press/press2009/pr_2009october12_ii.htm
2. Article from a big internet content providing website 2circles: http://sv1.twocircles.in/node/167299
3. Snippet from an Orkut community webpost: http://www.orkut.co.in/Main#CommMsgs?cmm=687469&tid=5392222975046910284
4. Another from TwoCircles: http://twocircles.net/2009oct13/jamia_millia_students_attend_global_student_summit_south_africa.html

I congratulate her for all her achivements so far.
I also wish her the very best in her all future endeavors.
(Definitely, I will be at your side darling: Like always, for ever.)

And now, abiding by the categorical attribute of this blog 'Discussions For IT People', I am also posting a computer software related advice. It is about the use of 'nohup' command in unix based machines. 'nohup' is used to start a process which has to keep running when the shell is closed.eg.
# nohup ping -i 60 > anwar.log &

And also, abiding by the dedication and romance for my best pal ever, I have invented a full form of nohup- Non Occasional Hands Up. Simply because a process run using nohup command is always up. This also resembles the way I am always up for her. And, I always do hands up when caught :) Jokes apart, the thoughts may sometime go in background, but they are always running.

One sher from an anonymous writer just before concluding:
Ek Muddat Se Mere Haal Se Beghaana Hai,
Jane Zaalim Ne Kis Baat Ka Bura Mana Hai,
Main Jo Ziddi Hun To Wo Bhi Ana Ka Qaidi,
Mere Kehne Pe Kahan Use Chale Aa na Hai.

With this light note I take your leave as of now. Imaginations of the same have again started setting me into a pool of creative emotions.
Take care readers while I am also putting efforts in a very serious guide book on Unix for everyone. And, it will be free.
Cheers ;)

-- Mohd Anwar Jamal Faiz
Toughjamy@yahoo.com
+91-8888327658

Friday, August 31, 2012

SCP command for secure copy or transfer of files between two machines or servers.


Sometimes it is required to copy files from or to a remote server. Sometimes you may also want to copy files from one remote server to another remote server, without passing traffic through your PC. scp command line utility is a neat tool/command to securely copy files over ssh, between Linux, Mac or Windows.

It is important to note here that scp stands for secure cp (copy). It means that you can copy files across ssh connection. The connection will be securely encrypted, it is a very secure way to copy files between computers

Syntax of SCP command:

scp [[user@]from-host-addr:]source-file [[user@]to-host-addr:][destination-file]

from-host-addr
Is the name or IP of the host where the source file is, this can be omitted if the from-host is the host where you are actually issuing the command
user
Is the user which have the right to access the file and directory, that is supposed to be copied in the case of the from-host, and the user who has the rights to write in the to-host
from-host-addr
Is the name or IP of the destination where the source file is, this can be omitted if the from-host is the host where you are actually issuing the command
source-file
Is the file or files that are going to be copied to the destination host, it can be a directory but in that case you need to specify the -r option to copy the contents of the directory
destination-file
Is the name that the copied file is going to take in the to-host, if none is given all copied files are going to keep its names

There are a few options which you can explore on your own. Like –p , -q, -r (for directory) and –v etc.

My small example:
scp -r user@x.x.x.x:/anwar/jamal/faiz /destination/folder/on/present/machine
Then it asks for password for user on machine x.x.x.x.
Give that. And, see task being accompalished!!

Some quick SCP commands variation that I use are as follows:

Following is going to copy all files with .txt extension to the folder /home/user in the abc.server.com host
scp *.txt user@abc.server.com:/home/user/

Following is going to copy all file from server to ur computer
scp username@server:/home/username/file_name /home/local-username/file-name

Following is used to copy files from a remote server to another remote computer
scp user_name1@server1:/home/user_name1/file_name user_name2@server2:/home/user_name2/
In above command files are copied from one server to the other. They are not going to pass through your computer. The data flow traffic is going to pass from one server to the other directly.
:) Cheers 
Anwar Jamal faiz

Thursday, November 3, 2011

Introduction to Linux FTP command by Anwar Faiz

This post is an introduction to the Linux FTP command. I will discuss in short, the FTP commands, ‘l-variants’, ‘!-variants’, and ‘m-variants’ command in FTP.

To start with, let me tell you that ftp command relates to the File Transfer Protocol. A typical use of the command ftp is for remotely copying, renaming, and deleting files.

For instance:
ftp abc.anwar.edu
This command will attempt to connect to the ftp server at abc.anwar.edu. If it succeeds, it will ask you to log in using a username and password. In case it is a public ftp server, it often allows you to log in using the username "anonymous" and your email address as password. After you are logged in you can get a list of the available ftp commands using the simple help function:
ftp> help
This lists the commands that you can use to show the directory contents, transfer files, and delete files.

Now let us analyze what you can do once you are in FTP command mode. The Shell prompt at this time typically becomes as ftp>.
You can type one of many commands available now to achieve different results.
For instance, ftp> ls
This command prints the names of the files and subdirectories in the current directory on the remote computer.
In a similar way, ftp> cd customers
This command changes the current directory to the subdirecotry "customers", if it exists.
In the same manner, ftp> cd ..
Changes the current directory to the parent direcotry.
Now there can be another variants of these commands too. Because remember now you are in a 2 computer zone. One is your host system from which the ftp command is run. Another is your remote system that has been FTPed here. So for these you can use a prefix ‘l’ befor above command to traverse through the directory structure of the local computer. Obviously ;) local means host system.
For example, ftp> lcd images.
Changes the current directory on the local computer to "images", if it exists.

Now we can directly land into serious discussions. First of any such discussion is about the modes of transfer. There can be two modes of transfer of files. One is ‘ascii’ and another is ‘binary’.
For example, ftp> ascii
Changes to "ascii" mode for transferring text files.
And ftp> binary
Changes to "binary" mode for transferring all files that are not text files.

The next point in discussion is about the transfer of files. After all, it is only for which the FTP command is all about.
So here comes the first one GET command.
Using ftp> get image1.jpg
You can download the file image1.jpg from the remote computer to the local computer.
It is warned that in case there already is a file with the same name it will be overwritten. Obviously you may smile over this warning ;)

And now comes the command for Uploading data, the PUT command
The command ftp> put image2.jpg
Uploads the file image2.jpg from the local computer to the remote computer. Again the same warning of file overwriting if file exists.

Using ‘!’-variant commands in ftp you can achieve results on local computer.
ftp> !ls
A '!' in front will execute the specified command on the local computer. So '!ls' lists the file names and directory names of the current directory on the local computer.

The last of such serious ( please smile again ;) what serious?). Ok. So the last one of such serious discussions would be the ‘m’-variant commands of get and put.
ftp> mget *.jpg
With mget you can download multiple images. This command downloads all files that end with ".jgp".
ftp> mput *.jpg
Uploads all files that end with ".jgp".
ftp> mdelete *.jpg
Deletes all files that end with ".jgp".

The blogpost would remain incomplete if I do not tell about the last point.
ftp> quit
This command exits the ftp program, and lets you return on the normal shell prompt.

With this I end this blogpost. I guess, it is sufficient to begin with and in a typical day to day job. For more details and examples, you may like to visit the website FTP tutorial from About.com. Take care :)

Monday, July 11, 2011

ulimit to set linux resource for testing

Recently I started using ulimit. I can seriously recommend ulimit utility as an awesome tool. Its location is /usr/bin/ulimit. Before begining let me accept that the better title for this post would have been 'how to use ulimit on linux' or 'setting resource limit and unset using ulimit', or better still, 'what is ulimit?'. [Huh..but what is wrong with my title ;) ]

Coming back, You can use 'ulimit' to set or display a resource limit. The available options are listed below. The limit for a specified resource is set when the limit is specified. The value of limit can be a number in the unit specified with each resource, or the value unlimited. I dedicate this post to my fellows in my team. My team including my manager is really great.

Back to the ulimit, the various ulimit Command options are as follows:

-a
Lists all of the current resource limits.
-c
The number of 512-byte blocks on the size of core dumps.
-d
The number of K-bytes on the size of the data area.
-f
The number of 512-byte blocks on files that can be written by the current process and its child processes (files of any size may be read). On file systems (such as vxfs file systems) that support large files, setting this limit to unlimited represents the largest file size supported on the file system. See ``Notices'', below.
-m
The number of K-bytes on the size of physical memory.
-n
The number of file descriptors plus 1.
-s
The number of K-bytes on the size of the stack area.
-t
The number of CPU seconds to be used by each process.
-v
The number of K-bytes for virtual memory.
If no option is given, -f is assumed; that is, you can specify a limit with or without the preceding -f option, and both cases are interpreted as an attempt to raise the file size limit.

There is a provision of hard and soft limit. i have never tried that, but in case yo want to explore more you can search ulimit man pages. or can even refer Click

I am attaching screenshot of ulimit -a option. this would clearly show all the limits currently set:



There are two important operands:

1) limit
Gives the resource-specific limit to use as the new resource limit.

2) unlimited
Sets the largest allowable resource limit. It is necessary to set limit to the value unlimited for access to large files.

It is important to note that ulimit works across all flavors of linux. Even on WindRiverLinux. This comes as a very handy tool for QA people testing on unix environments. Once set, you can reset the limits again using the same command. You can also make it unlimited. Following two scenarios are of great use while testing:
1) ulimit -c unlimited: this will make maximum possible space available for making core dumps. This will help fruitful core dump creations to be consumed both by the QA and dev people.
2) ulimit -v unlimited. this will make maximum possible space available for virtual memory. So this can also regulate or simulate low memory conditions.

I guess this much is enuff. Rest you can explore. Please do not forget clicking on a few Advertisements. Google will give ranking and points to my blog, you will get good contents always. ;) rest you know!!!

Wednesday, July 6, 2011

Terminal (Shell) on Mac OSX or Unix continues to show a folder even if it is deleted or renamed

I have logged this defect with Apple. But since then I have only been told it is legacy Unix behavior. And Unix is supposed to behave that way. In any case, I find it valuable to share this now.

-------------------------------------------------------------
This is already present on Apple Website since 19th March 2010 and has one response in addition to the emails. Read Further Apple Mac OSX Bug By Anwar Faiz.
-------------------------------------------------------------
Make a folder, let us say "xyz" on desktop and cd to this location on a terminal using 'cd' command.
Now rename that folder to "abc".
Now type 'ls' command on Terminal to see the content of folder "xyz", it still shows.
In addition if you use 'pwd' command, it still shows that you are in directory "xyz"
Worse is that even if you delete the folder "xyz" and empty trash. Even then using 'pwd' command would show your present working directory as "xyz" folder.
--------------------------------------------------------------


I got a detailed response for this. The same can be read over at same Apple Official website also. I am thankful to Mr. Bob Harris from New England, USA, who took time to explain.:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All expected behavior.

The 'cd' command makes a chdir() system service call, which opens the target directory and stores the open file descriptor in the process.

When you rename the folder, that just changes the directory entry in its parent folder, it does not change the file system inode for the directory nor does it affect already open file descriptors to the directory.

So when you do an 'ls' with no path, the 'ls' command will ask the file system for the '.' (current directory), which the file systems knows to use the current working directory it already has saved in the process.

This is how Unix has worked forever.

'cd' and 'pwd' are bash built-in commands, so bash has cached the last 'cd' path, and when you issue 'pwd', bash just echos the cached path information. It does not verify anything before displaying the path.

If you want to see the real current path, then try using

/bin/pwd

this will do the more complex reverse path reconstruction, which can have some unexpected responses, because of symbolic and hard links that may have been used to navigate down to the current directory location.
Worse is that even if you delete the folder "xyz" and empty trash. Even then using 'pwd' command would show your present working directory as "xyz" folder.

Again, bash is just echoing the cached path that bash last knew about.

Also since the process still has an open file descriptor to the directory open in the process as the current working directory, the file system will defer the actual directory delete until after that file descriptor is closed.

The fact that a file or directory will not be truely deleted if it is still open, allows an application to continue to use a file if it has it open, even when some other process deletes the file. This can be good for the application, but if that was a huge file and you were trying to free up space, you would not see the space returned until after the process that has the file open, closes the file.

You can use the 'lsof' command to find what processes have what files/directories open.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In addition, it was advised that, if I have additional Unix or Terminal related questions it would be best to post them in the Mac OS X Technologies > Unix Forum. So, one place where you can also redirect yourself for taking other unix Vodka Shots is Apple Unix Discussions

Thursday, June 30, 2011

Tar command in Linux [additional notes in Freebsd] to archive and extract contents (तार कमांड इन लिनुक्स)

'tar' command in linux is used to make archive and also to extract from the tar archive. Actually TAR is a file compression format and linux supports it very well. It is also used synonymously with TGZ sometimes. The same 'tar' command is used to create as well as extract from a tar.


A) To Create linux tar gz (Gzip) archive
tar -czvf myarchive.tgz mydirectory/
-c, –create create a new archive

In Freebsd there is no -v -z options so simple command like :
tar -cf would do it.

If you use -w , then it will prompt you at every file. -v will give you a verbose output at each line.

It is important to note that .tgz is the same thing as .tar.gz


B)To Create linux simple tar archive without any compression
tar -cvf myarchive.tar mydirectory/


C) For Extracting linux tar archive:
tar -xzvf mystuff.tgz
-x tells to extract the files form the tar archive
You can remove z if it is a simple tar file.

There are a lot more options available that you can get to know using man or --help. Also, a good book on linux will help you learn more on file compression decompresion and tar zip commands etc. The things i mentioned, will suffice your daily needs anyways. Cheers ;)

Thursday, February 17, 2011

Unix Commands related to Handling files

Without an introductory speech let me come directly to the point.
Listing files in a directory

ls
list the files in the current directory
ls -a
list ALL files, even ones which begin with a dot, which are normally omitted
ls -s
list files, with their sizes
ls -l
list files, giving full details about each file
ls -al mydir/
list all files in directory mydir (including those beginning with a dot), giving full details about each file
ls *.c
list the files which end ".c"
ls mydir/
list the files in directory mydir


Moving or renaming files (IMHO please consider both the same if you are on Unix flavored OS or on Mac)
Examples:
mv oldname newname
rename a file
mv myfile mydir
move a file into another directory
mv myfile1 myfile2 myfile3 mydir
move several files into another directory


To Copy files
Examples:
cp oldname newname
make a copy of a file
cp myfile mydir
make a copy of a file in another directory
cp myfile1 myfile2 myfile3 mydir
make a copy of several files in another directory


To Delete files
Examples:
rm file...
delete the specified files
rm -i file...
ask for confirmation before deletion
rm -f file...
don't ask for confirmation before deletion. BE CAREFUL!
rm -r directory
Delete directory and everything in it. BE CAREFUL! To remove empty directories, see rmdir
rm -rf directory
Delete directory and everything in it, without asking for confirmation. Hey man its not the magic. Actually –rf tells the OS to suppress asking for confirmation. Actually there is never a magic in Software Arena. It’s all how deeper you go, and how diversified the developers approached to a problem. But defects/bug usually come as a magic!! (Some say, if you understand a woman, it is a magic in itself. Have I understood my Girlfriend and would be wife yet!!!!)


You can write me at toughjamy@yahoo.com.
To Know me professionally visit ..Linked In..
You can befriend me at ..FaceBook..
Read jokes at ..Jokes Limitless..
You can also know more about me at ToughJamy : An Informal Me!!

Using Process Explorer in Windows XP Server Vista and Win7

In Order to know what all processes are running and to forcibly terminate any you need to explore Process explorer. In Windows platform this can come easily by opening Taskbar. Ctrl+Alt+Delete and selecting Taskbar is historically the method to reach there.

You can instead of killing a process, suspend it (right-click on a process to see this option). This is useful in the case if program stuck in an endless loop.

In addition, if you wanna know what is the process identification (term better known as PID historically since the advent of Unix based Systems), then Open the program, then switch to Process Explorer. In the top-right corner there is a target icon (see concentric circles). Clicking this icon and dragging it onto the program you want to see, the Process Explorer will highlight the process.

Thursday, August 5, 2010

Bewitched Apps using the Genie Effect or Slow Motion Effect in Mac OS X

Have you heard about famous Genie Effect in Mac. It is also regarded as Slow down effect.

You can see this by holding down shift when clicking on the window minus button or documents in the dock. As discussed, I am showing another use of this Genie effect that would make UI of apps in Mac distorted yet perform well.


The trick is to Open up any App or say Safari browser and navigate to a nice long web page.

For instance you can visit MeOnShow.Com or even open one of my another blog Jokes Limitless


Now Launch up a Terminal and type “Killall Dock”. Do not press enter at this time. Also make sure that your App or Safari window is in the background and Terminal is your active window. Now Hold down the shift key and click the minimize button on your App or Safari window. Now in midway of minimizing window press the enter key on terminal to execute your Terminal command. You will be amazed to see that your application, or Safari window in this case, would stuck in a distorted shape. You can scroll through webpage or App, navigate and use your App, Click On buttons, do interaction, in a distorted shaped window. This is the secret logic and trick behind my famous Bewitched Apps Trick that has amazed many of my colleagues in TCS, CSC, Patni, HCL, Adobe and Amazon.


You can write me at toughjamy@yahoo.com.
To Know me professionally visit ..Linked In..
You can befriend me at ..FaceBook..
Read jokes at ..Jokes Limitless..
You can also know more about me at ToughJamy : An Informal Me!!

Happy Programming and Happy Hacking.

How to remove Thumb.db file

We all know that Thumb.db file is a cache of the current picture in that directory. But sometimes it become necessary to remove it. In order to remove it go for following step:

1--> open "WINDOWS EXPLORER".
2--> go to "TOOLS".
3--> open "FOLDER OPTIONS".
4--> go to "VIEW".
5--> see 1st section "FILES & FOLDERS".
6--> click on the "DO NOT CACHE THUMBNAILS".

Now the thumbnail file will be removed from the computer system. And once you do this the file will be never created.

Some Useful shortcuts tricks and tips in Mac OS X

Today I am writing about several shortcuts and tricks in Mac OSX Platform. Some may be know to few people but some may really amaze you.

a) Select text in your browser and then drag and drop it onto your desktop. There will be a basic text file with your text in it.

b) cmd-click Finder window title: It shows a Pop-up menu showing path to current folder/document

c) Command Key and Tab Key can be used to cycle through your running apps as was done in Win platform using tab key alone.

d) Many do not know that you can change the style of the text/icons of a window by command clicking on the little button in the top right of the window of a program. That small button has more functionality too. Explore!!

e) Have you heard about famous Genie Effect in Mac. It is also regarded as Slow down effect. You can see this by holding down shift when clicking on the window minus button or documents in the dock. I will further explain this in Genie effect blog post separately.

f) Voice over Utility:
You can use apple logo key and F5 to launch Voice over utility App. You may also find this by default at /application/utilities/voiceover. I will write about this utility at some later time but if you explore yourself, you will be more benefitted.

g) Resizing a column divider in a Finder window is simple. But there is yetr another trick. Press Alt-click and drag column divider in Finder column view resizes columns evenly. This would resize width of columns in all finder windows opened.

h) Pressing F11 would engage expose and move all windows to the edge of your screen

i) Negative Vision Trick.
I discovered this a year earlier. Since then I used this many times to stun my younger sis, or for that matter my MBA Wife. Use control+alt (option)+command+8. This would make your screen go like a negative vision of your screen. You can do again the same to revert back.

Write your opinion.

You can know more about me at ..Linked In..
You can befriend me at ..FaceBook..
Read jokes at ..Jokes Linitless..

Emac from Unix to Mac.

The command emac can be used to play some games or some refreshing exercise once you get bored through your usual routine job. I do not know about its history but can be surely searched at Wikipedia. But today I will tell about some tricks with emac.

1) One trick is pressing control+option+command+8.

Another one is going to terminal then typing "emacs", then press "esc" and then "x", then type "doctor" or "tetris" or “life”. The effects are that ‘Tetris’ would pop up the classic ‘tetris’ game, ‘life’ shows the cell division process.

2) If you are a little bit bored, you can try M-x hanoi. If you are considerably bored, give it a numeric argument. If you are extremely bored, then try an argument of 9. Sit back and watch the Hanoi Towers been created.

3) If you want self involvement, try M-x gomoku, which plays the game Go Moku with you.

4) M-x dunnet runs an adventure-style exploration game, which is a bigger sort of puzzle.

5) As told, M-x tetris runs an implementation of the well-known Tetris game. What was not told is that, M-x snake provides an implementation of the famous Snake game.

6) When you are frustrated, try the famous Eliza program. Just do M-x doctor. End each input by typing RET twice.

7) When you are feeling strange, type M-x yow.

8) The command M-x zone plays games with the display when Emacs is idle.
So in this way you can counter react to the boredom at work if it occurs on Unix or Mac platform. One’s who are in luck to always deal with black screen of traditional Unix based system would really know what I mean when I speak of boredom ;)

And yes, do not forget ending with emcs—ctrl+q then ctrl+c .

So, Happy Emac-ing (I prefer calling e-mack-ing)