Monday, 10 September 2012

Getting the Directory Size in Unix/Linux


On some Day, we might need to find the size of the directory through the Unix command or through the SSH Client. To get a Directory size, use the following commands.

praba@treadstone$ ls
Java     build   source    lib
praba@treadstone$ du –sh build
2.6M build


Atleast I post this for myself to get it back, if I forgot in nearby future.

Here ‘s’ refers ‘size’ and ‘h’ refers to the ‘human readable’ format. There are many more options available with command ‘du’. To know it more about. Execute

>man du


To get the File System Disk Space, use 'df'. displays the amount of disk space available on the file system containing. 



praba@treadstone$ ls

Java     build   source    lib

praba@treadstone$ df –kh build

Filesystem              size     used      avail       capacity         Mounted on
cevic:/f                   2.7T    2.4T       225G        92%        /praba/Builds/F1


here 'h' refers the 'human readable' format. 'k' refers the block size. 

>man df option will let us know the more option. 


There will be huge time difference between the 'du' and 'df' commands. Try executing the 'df' for entire file system. 'du' for knowing the particular file size. 






~Prabakaran

Thursday, 14 June 2012

Fedora Core RedHat Linux:  Samba server and Windows can’t see the file each other
On certain times, you don’t get access to the samba files from the fedora redhat, the error message shown as “Windows cannot access the specified path, you do not have permission to access, Contact network Administrator”
This was one heck of the problem most of us will face with Samba server. Please do execute the following commands so that you can overcome the problem.
I am curious about the commands that are described as below; even I got commands from the internet. If any of you knows about the meaning of these commands, please post it as your comments.

Smb.conf file should look as follows
[global]
        workgroup = workgroup
        security = share
        guest ok = yes

[Share_Name]
        comment = Movies and TV
        path = /home/user/Videos
        read only = no
        guest ok = yes
;       browseable = yes

Check for the firewalls are open to access the samba, ports are 137/138/UDP to 139/TCP.
Restart the smb.service by using the command
Ø  /bin/systemctl restart smb.service
Now from the windows, try to access the Samba files. If you get the error as
“Windows cannot access the specified path, you do not have permission to access, Contact network Administrator”
Try executing the following command.
Ø  su
Ø  setsebool -P samba_export_all_rw 1 
I am not clear about the above commands, from my knowledge I guess. Setsebool enables the access to samba files by setting the flag ‘1’, to disable flag to be set to ‘0’.
Now try accessing, Hope it works for you now. Again if not working, try restarting the Samba Services by
Ø  /bin/systemctl restart smb.service
Ø  /bin/systemctl restart nmb.service

Still if you are getting the same error in accessing the Samba files. Found some more interesting things, execute the following commands
Ø  getsebool –a | grep samba
It displays the following
samba_create_home_dirs --> off
samba_domain_controller --> off
samba_enable_home_dirs --> off
samba_export_all_ro --> off
samba_export_all_rw --> off
samba_run_unconfined --> off
samba_share_fusefs --> off
samba_share_nfs --> off
sanlock_use_samba --> off
use_samba_home_dirs --> off
virt_use_samba --> off 
if samba_share_fusefs --> off was off, try executing the following command
setsebool samba_share_fusefs on 

Restart samba service, and now the error will not appear while accessing the samba share files. JJJJ


..Prabakaran