Why is du command showing incorrect results [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
The below output showing 21GB files each.
[root#myhost data]# ls -l
total 100092
-rw-rw---- 1 ora4 ora4 **22548586496** Dec 18 21:09 temp01.dbf
-rw-rw---- 1 ora4 ora4 **22548586496** Dec 18 19:38 temp02.dbf
But when i used du command, its shows only 49MB.
[root#myhost data]# du -sh *
49M temp01.dbf
49M temp02.dbf
Could you please let me know, how to correct the values.

execute the ls -lh ls -l. will display the size in the bytes. du -sh in du command you are mentioning the h for displaying the result in human readable format. If you check with the du it will display the output in kb(kilo bytes). Compare the results with ls -lh and du -sh *.

Related

difference between /bin/ls and /usr/bin/ls [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
It seems that both /bin/ls and /usr/bin/ls have the same inode (and the same sha-256 hash) but the number of hard links displayed by ls -li /usr/bin/ls /bin/ls is 1 instead of 2 :
user#debian:~/Documents/Unix$ ls -lai /usr/bin/ls /bin/ls
8258848 -rwxr-xr-x 1 root root 147176 24 sept. 2020 /bin/ls
8258848 -rwxr-xr-x 1 root root 147176 24 sept. 2020 /usr/bin/ls
Could somebody explain me what I have misunderstood?
I was puzzled for a while by this too, until I discovered this:
$ ls -ld /bin
lrwxrwxrwx 1 root root 7 May 31 02:39 /bin -> usr/bin
So /bin is just a symlink to /usr/bin, and there is really only one link to the file.
There are no differences between ls utility. You should know the difference is only between /bin and /usr/bin directories. /bin directory contains all programs that are used by system admin and all others users. /bin directory we can access whenever we want, but /usr/bin is accessible only for users that are locally logged.

Is there a difference between commands "cp -P" and "cp -d"? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
man cp says:
-d same as --no-dereference --preserve=links
-P, --no-dereference never follow symbolic links in SOURCE
I test these two options and find they are same in the practice. Both just keep the symbolic links regardless of whether the symbolic(soft) link is valid or not.
Any ideas?
Thank you.
They have the same effect on symbolic links. But -d has the additional effect of preserving hard links. That is, with -d or --preserve=links, if an invocation of cp encounters multiple links to the same file, it will create multiple links to the same file in the destination. Ordinarily cp doesn't pay attention to hard links and creates files that happen to have identical contents if two source files are hard links.
$ touch foo
$ ln foo bar
$ mkdir d; cp -d foo bar d
$ mkdir P; cp -P foo bar P
$ ls -log d P
P:
total 0
-rw-rw-r-- 1 0 Apr 11 17:09 bar
-rw-rw-r-- 1 0 Apr 11 17:09 foo
d:
total 0
-rw-rw-r-- 2 0 Apr 11 17:09 bar
-rw-rw-r-- 2 0 Apr 11 17:09 foo

Soft Link redirection in linux [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I have created a soft link as follows:
/bip/etl>ln -s /bip/etl bipet
And now can see the soft link being created as well..
/bip/etl>ls -lrt |tail
-rw-rw-rw- 1 cdtbipx cduserg 24988174 Jun 19 19:17 227015716_WLR3PSTN_Filtered_06202016_5of6.csv.gz.gpg
-rw-rw-rw- 1 cdtbipx cduserg 23857587 Jun 19 19:17 227015716_WLR3PSTN_Filtered_06202016_6of6.csv.gz.gpg
drwxrwxrwx 1082 prod release 61440 Jul 3 02:51 WSC
drwxrwxrwx 5 oracle oinstall 4096 Jul 4 01:22 dsl
lrwxrwxrwx 1 cdtbipx cduserg 8 Jul 4 08:43 bipet -> /bip/etl
However, I cannot refer to the soft link bipet while I try to search a specific file in the concerned folder.
ls -lrt /bipetl/227015716_WLR3PSTN_Filtered_06202016_6of6.csv.gz.gpg
ls: /bipetl/227015716_WLR3PSTN_Filtered_06202016_6of6.csv.gz.gpg: No such file or directory
What am I doing wrong here?
You created a link bipet in directory /bip/etl (current working directory when you did ln).
You you should do:
ls -lrt /bip/etl/bipetl/227015716_WLR3PSTN_Filtered_06202016_6of6.csv.gz.gpg
Or create the link using (assuming you have privileges to write to the /):
ln -s /bip/etl /bipet
And then you can do:
ls -lrt /bipetl/227015716_WLR3PSTN_Filtered_06202016_6of6.csv.gz.gpg

Unknown users rights (-????????? ? ? ? ? ? myFile.php) [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
I have some weirds user rights on my files.
Log as user1, I have set user2 owner of the files. It did worked.
-rw-r-xr-x 1 user2 user2 21090 Jun 18 16:28 myFile.php
drw-r-xr-x 2 user2 user2 4096 Jun 18 16:30 font
But then, when I log with user2 I Have this weirds unknown rights.
-????????? ? ? ? ? ? myFile.php
d????????? ? ? ? ? ? font/
Top directory that contains these files has no "x" bit set.
chmod u=rwx test2/; ls -l test2
total 4
drwxr-xr-x 2 user group 4096 Jun 19 14:43 dir
-rw-r--r-- 1 user group 0 Jun 19 14:43 file
chmod u=rw test2/; ls -l test2
ls: cannot access test2/file: Permission denied
ls: cannot access test2/dir: Permission denied
total 0
d????????? ? ? ? ? ? dir
-????????? ? ? ? ? ? file
To fix this, please add "x" bit to following section of root directory. Usually "group" part is relevant but it might be "others" or "user" depending on your situation.
chmod g+x /path/to/directory
For further reading please consult http://www.linux.com/learn/tutorials/309527-understanding-linux-file-permissions

When copying in linux do permissions and owners persist? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
When I copy with a command such as:
cp -R /myfolder /home/backup/
Will the permissions such as 775 (drwxr-xr-x) persist?
Will the owner 'danny:danny' persist, or will the owner change to the person who actually made the copy?
you can run cp -a to preserve the ownership. Note that to preserve root permissions, you must run with sudo.
Without this flag, ownership is not preserved.
If a user copy a file he will become the owner of it.
$ mkdir d1 && touch d1/f1
$ sudo cp -R d1 d2
$ ls -l
drwxr-xr-x 2 root root 4096 Oct 28 17:58 d2
$ ls -l d2/
-rw-r--r-- 1 root root 0 Oct 28 17:58 f1
It is cp -p to preserve the timestamps,ownership and permissions check out http://unixhelp.ed.ac.uk/CGI/man-cgi?cp
Thanks & Regards,
Alok Thaker

Resources