Removing old users’ home directories from Linux server [closed] - linux

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
We have an NFS server with thousands of users home directories. I did a lot of searching and man page reading and I can't seem to figure this out.
I want to remove the home directories of the users that are no longer with us. Basically anyone that hasn't logged in and made changes to their home folders in over a year.
The snag i keep hitting is every tool i see (ls, find, etc) will give me the listing on the last time a directory was modified but not the contents inside.
Take the user Joe for example.
/data/Users/joe/Windows# ls -lt
drwxrwx---+ 2 1079 nhsstaff 4096 2008-07-31 15:13 Cookies
So judging from this output you would think this folder had not been access since July 7th 2008.
But when you look inside the directory:
`root#smb0:/data/Users/joe/Windows/Cookies# ls -ltr
-rwx------+ 1 1079 nhsstaff 92 2009-02-17 03:16 default#sun[1].txt
-rwx------+ 1 1079 nhsstaff 86 2009-02-17 03:16 default#ig[1].txt
-rwx------+ 1 1079 nhsstaff 136 2009-02-17 03:16 default#google[1].txt
-rwx------+ 1 1079 nhsstaff 104 2009-02-17 03:16 default#dell[1].txt
-rwxrwx---+ 1 1079 nhsstaff 32768 2010-04-26 07:53 index.dat`
You can see files have been changed since April 26th 2010.
So to sum up, i need a way to search and sort when the last time a home directory was used.

run this command:
find /data/Users -mtime +365 | awk '{print $1}' | cut -f2 -d"/" | sort\
| uniq -c | awk '{print $2}'
This set of commands will give you list of all those users, who have not modified their home folders for more than a year.
If you want script to auto delete those folders through script, I can provide it as well.

Related

What does the -s command show? and why it changes with -h? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
What does the the first column shows when using the -s command with ls command?
$ ls -als
41 -rw-r--r-- 1 user user 165287 Jul 10 11:18 '.tutorial.term'
1 lrwxrwxrwx 1 user user 18 Jul 1 08:40 .bash_profile -> /home/user/.bashrc
3 -rw-r--r-- 1 user user 2355 Jul 1 08:40 .bashrc
Does it show the number of blocks used for that file? or the size of blocks used for that file?
If I add the -h command to the mix, which prints sizes in a human readable format, why does the first column changes too? and why does the value differs from that in the 6th column which represents the actual size of the file?
$ ls -alsh
41K -rw-r--r-- 1 user user 163K Jul 10 12:34 '.tutorial.term'
512 lrwxrwxrwx 1 user user 18 Jul 1 08:40 .bash_profile -> /home/user/.bashrc
2.5K -rw-r--r-- 1 user user 2.3K Jul 1 08:40 .bashrc
as ls man page says, -s will print the allocated size of each file, in blocks
The size of a file and the space it occupies on your hard drive are rarely the same. Disk space is allocated in blocks. If a file is smaller than a block, an entire block is still allocated to it because the file system doesn’t have a smaller unit of real estate to use. reference
also when you use, -h option, it will change allocated block size and file content size into bytes to be human readable. So block size can be different from file size because, it often happens that file content won't use all allocated size
If you want to know why ls -l and ls -s give different sizes, read this answer. Basically, -l returns the actual size of the file while -s returns the size in the filesystem. h makes all sizes human-readable, including the ones for -s and -l.

Mac OSX file permissions has '#' - how to remove that '#' [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
How can I remove that '#' character from the file permissions?
'#' in file permissions for Mac/OSX machines, is used to show that an extended attribute is set with this file.
Tried chmod 755 galaxy-ansible.yml but that didn't help.
Tried echo | chmod -E galaxy-ansible.yml, didn't help (even with using sudo).
Tried xattr -d galaxy-ansible.yml, that didn't help either (even with using sudo).
I even did the above operations as root user, still '#' character is not going away from file's permissions.
[arun#MacBook-Pro-2 ~/aks/anisble] $ ls -l# galaxy-ansible.yml
-rwxr-xr-x# 1 arun staff 270 Dec 22 12:31 galaxy-ansible.yml
com.apple.quarantine 67
My ~/aks folder is mapped to a CentOS vagrant box and if I'm on the vagrant box, doing ls -l doesn't give me '#' (as it's not a Max/OSX machine):
-rwxr-xr-x. 1 vagrant vagrant 270 Dec 22 00:12 galaxy-ansible.yml
On my Mac/OSX machine, there are other .yml files but those don't have '#' in the file permissions so I'm trying to remove '#' from galaxy-ansible.yml file (on Mac machine).
Right now the whole roles/.. folder has '#' character for any folder/files.
-rwxr-xr-x# 1 arun staff 1132 Dec 21 17:12 README.md
drwxr-xr-x# 3 arun staff 102 Dec 21 17:12 defaults
drwxr-xr-x# 3 arun staff 102 Dec 21 17:12 handlers
drwxr-xr-x# 4 arun staff 136 Dec 21 17:12 meta
drwxr-xr-x# 5 arun staff 170 Dec 21 17:12 tasks
drwxr-xr-x# 7 arun staff 238 Dec 21 17:12 templates
The following commands helped in clearing the extended attribute at file / folder(recursive) level.
xattr -c <yourfilename>
or
xattr -cr <yourfoldername>

how to open all shortcuts files from a directory with chromium-browser in one command [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
On ubuntu 16.04, i have a directory with these files :
-rw-rw-r-- 1 user0 user0 86 jui 7 21:32 vim html picker.url
-rw-rw-r-- 1 user0 user0 104 jui 7 21:32 cocoonjs build android apk.url
-rw-rw-r-- 1 user0 user0 61 jui 7 21:32 Simple Modal Window - Codepad.url
-rw-rw-r-- 1 user0 user0 96 jui 7 21:32 cocoon.js android build apk+++.url
-rw-rw-r-- 1 user0 user0 44 jui 7 21:32 CodePen - Front End Developer Playground & Code Editor in the Browser (1).url
The file "vim html picker.url" have this information :
--> cat vim\ html\ picker.url
[InternetShortcut]
URL=https://github.com/KabbAmine/vCoolor.vim/blob/master/README.md
what i want to do is open all of theses files from this directory in tab in my chromium-browser.
i have tried this in my gnome-terminal :
chromium-browser *.*
but chrome open the text information : URL=https://github.com/KabbAmine/vCoolor.vim/blob/master/README.md and not the url itself :https://github.com/KabbAmine/vCoolor.vim/blob/master/README.md.
wich command allow my desired behaviour ?
grep "^URL=" *.url | cut -d= -f2 | xargs chromium-browser
should do the trick.
Explanation:
grep "^URL=" *.url - cut the line beginning with URL= from each file ending in .url
cut -d= -f2 - split each remaining line into parts delimited by '=' and output the second and all subsequent parts (i.e. the part after the first '=')
xargs chromium-browser - use the list of URLs as arguments to chromium.

Linux memory issue [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 7 years ago.
Improve this question
I have a problem on my server.
When i try to start my server, it says that "there no left space on device"
If i execute the command "df", I see that on directory if full.
/dev/mapper/owegdc_vg-owegdc_logs_lv
10321208 9797004 0 100% /opt/application/owegdc/logs
When i get to the logs directory here what i see
ls -lrta
total 368
drwxr-x--- 2 oweadm grpowe 16384 Jan 15 2014 lost+found
drwxr-x--- 7 oweadm grpowe 4096 Jun 18 11:55 .
drwxr-xr-x 2 oweadm grpowe 12288 Aug 4 10:20 apache
drwxr-xr-x 2 oweadm grpowe 4096 Aug 5 00:56 batches
drwxr-xr-x 2 oweadm grpowe 4096 Sep 10 13:43 expl
drwxr-xr-x 2 oweadm grpowe 327680 Sep 10 13:50 jonas
drwxr-xr-x 11 oweadm grpowe 4096 Sep 10 13:50 ..
du -sk
9642792 .
I tried things like 'lsof' but it didn't work...
Do you have an idea ?
Thx
You could just try something like
du | sort -h -r
That would list the directories on your disk, ordered by their size descending. The first directory in the output list is the biggest one.
Better, if you're looking for large single files instead of a directory, this answer on Unix & Linux gives useful information, especially this:
find . -type f | xargs du -h | sort -rn
The output is the same, but it lists files instead of dirs.

Cannot enter in centOS with any user [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am using cent OS Operating system without GNOME.
In the starting, it asks
localhost login:
Password:
It has one user named service under group name service whose password is also service.
I want to enter in OS by this user named service.
When I do this, it shows this lines
Last Login: Mon Feb 18 16:16:26 on tty1
-bash: /home/service/.bashrc: Permission denied
-bash-3.2$
I changed in /etc/sudoers, and add service ALL=(ALL) ALL, right below root ALL=(ALL) ALL, but it didn't work.
when I try to switch from root to service, it shows the same error.
EDITED
When I run ls -a -l | grep .bashrc, it shows
lrwxrwxrwx 1 root root 41 Feb 18 11:40 .bashrc -> /home/service/etc/version.symlink/.bashrc
-rw-r--r-- 1 service service 124 Feb 15 13:06 .bashrc-moved-1361167832
Help me. Looking for your kind response.
Well, according to the output of your ls -a -l | grep .bashrc command, I guess you have to issue this command as root :
chown service:service /home/service/.bashrc
This is nothing to do with sudo. Check the permissions on /home/service/.bashrc It should be owned by service:service. It should be also readable for that user.
/home/service itself should be owned by service:service and be have rwx rights for the owner and rx for the group.

Resources