WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: [SOLVED]help requested using the find command  (Read 3468 times)

aus9

  • Guest
[SOLVED]help requested using the find command
« on: May 04, 2013, 08:51:15 PM »
Hi

pre-amble....I am a simple coder and probably a slow learner?
before I ask my questions, I already know the following works for me

In building TCZs, some packages need special owner or permissions. Altho I have some things in my build script, I want to check the build folder quickly and these work so far. Changed pathway to a real package

Code: [Select]
sudo find /tmp/tcloop/cups -perm 640
/tmp/tcloop/cups/usr/local/etc/cups/snmp.conf
/tmp/tcloop/cups/usr/local/share/cups/files/cupsd.conf

sudo find /tmp/tcloop/cups ! -user root ! -group root
/tmp/tcloop/cups
/tmp/tcloop/cups/usr/local/tce.installed/cups

find -h --> gives some references and one section is:
Quote
-type X      File type is X (one of: f,d,l,b,c,...)

google gives me http://www.tuxradar.com/content/find-files-easy-way

Quote
File is of type 'x', one of:
f - regular file   d - directory   l - symbolic link    c - character device   b - block device  p - named pipe (FIFO)

Now if I did not know the octal number was 640, I can see that
Code: [Select]
ls -al /tmp/tcloop/cups/usr/local/share/cups/files/cupsd.conf
-rw-r----- 1 root root 4141 Oct 12  2011 /tmp/tcloop/cups/usr/local/share/cups/files/cupsd.conf
(so attempt)
sudo find /tmp/tcloop/cups -perm -rw-r-----
find: invalid mode 'rw-r-----'

(attempt 2)
sudo find /tmp/tcloop/cups -perm rw-r-----
find: invalid mode 'rw-r-----'

Now to look for setuid...google suggests http://linux-windowsfixes.blogspot.com.au/2012/06/how-to-find-setuid-setgid-files.html
Code: [Select]
sudo find / -type f \( -perm -04000 \) \-exec ls -lg {} \;
-rwsr-xr-x 1 root 15828 Oct 28  2011 /tmp/tcloop/polkit/usr/local/bin/pkexec
-rwsr-xr-x 1 root 8232 Oct 28  2011 /tmp/tcloop/polkit/usr/local/libexec/polkit-agent-helper-1
-rwsr-xr-x 1 root 9403 Oct 28  2011 /tmp/tcloop/Linux-PAM/usr/local/sbin/pam_timestamp_check
-rwsr-xr-x 1 root 26057 Oct 28  2011 /tmp/tcloop/Linux-PAM/usr/local/sbin/unix_chkpwd
-rwsr-sr-x 1 root 43224 Aug  1  2011 /tmp/tcloop/ntfs-3g/usr/local/bin/ntfs-3g
-rwsr-xr-x 1 root 69212 Sep  5  2011 /tmp/tcloop/util-linux/usr/local/bin/mount
-rwsr-xr-x 1 root 49884 Sep  5  2011 /tmp/tcloop/util-linux/usr/local/bin/umount
-rwsr-xr-x 1 root 10972 Nov  9 11:22 /tmp/tcloop/chromium-browser/usr/local/chromium-browser/chromium-browser-sandbox
-rwsr-xr-x 1 root 208232 Jul 28  2012 /tmp/tcloop/dbus/usr/local/libexec/dbus-daemon-launch-helper
-rwsr-xr-x 1 root 1341528 Sep 23  2011 /tmp/tcloop/Xorg-7.6/usr/local/bin/Xorg
-rwsrwxr-x 1 staff 511220 Aug  8  2012 /bin/busybox
---s-wx--x 1 staff 127144 Dec  8  2011 /usr/bin/sudo

setgid could use
Code: [Select]
sudo find / -type f \( -perm -02000 \) \-exec ls -lg {} \;
-rwsr-sr-x 1 root 43224 Aug  1  2011 /tmp/tcloop/ntfs-3g/usr/local/bin/ntfs-3g
-rwxr-sr-x 1 root 8864 Sep  1  2011 /tmp/tcloop/vte/usr/local/libexec/gnome-pty-helper


for lower case t  I can see that chmod can be used to set the t either
Code: [Select]
(setuid)
chmod u+t
(setgid)
chmod g+t
(whatever others is called
chmod o+t

Questions
1) What am I doing wrong in my failed (attempt)  attempts?

2)  How do you set   perm   rw-  r --   --T ?

The closest I have got thru google is
http://aplawrence.com/Basics/perms.html

not bad for t but not sure its showing T

3) What is its octal number?

Thanks for reading and thanks for any enlightenment

« Last Edit: May 04, 2013, 10:19:10 PM by aus9 »

aus9

  • Guest
Re: help requested using the find command
« Reply #1 on: May 04, 2013, 09:32:16 PM »
sorry additional question unrelated to building but might hint to me I need to rebuild??

Does this look normal?

Code: [Select]
ls -al /mnt/sda3/home/
total 12
drwxr-xr-x  3 root root  4096 Mar  3 08:17 ./
drwxr-xr-x 10 root root  4096 Apr 25 13:30 ../
drwxr-s--- 23 tc   staff 4096 May  5 09:28 tc/

I could not spot anything in my profile so it must be set elsewhere?

aus9

  • Guest
Re: help requested using the find command
« Reply #2 on: May 04, 2013, 09:41:12 PM »
ok ignoring my unusual group sticky  I think I have got a way of creating T

Code: [Select]
mkdir test3
chmod g-s test3
tc@box:~/test$ ls -al
total 12
drwxr-sr-x  3 tc staff 4096 May  5 09:41 ./
drwxr-s--- 22 tc staff 4096 May  5 09:36 ../
drwxr-xr-x  2 tc staff 4096 May  5 09:41 test3/
chmod 740 test3/
chmod o+t test3/
ls -al
total 12
drwxr-sr-x  3 tc staff 4096 May  5 09:41 ./
drwxr-s--- 22 tc staff 4096 May  5 09:36 ../
drwxr----T  2 tc staff 4096 May  5 09:41 test3/
« Last Edit: May 04, 2013, 09:44:12 PM by aus9 »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11670
Re: help requested using the find command
« Reply #3 on: May 04, 2013, 09:42:22 PM »
Hi aus9
Octal is a base 8 numbering system. Counting runs from 0 - 7, 10 - 17, 20 - 27, ... 70 - 77, 100 - 107, etc.

aus9

  • Guest
Re: help requested using the find command
« Reply #4 on: May 04, 2013, 09:45:23 PM »
editted again with possible solution
« Last Edit: May 04, 2013, 10:20:30 PM by aus9 »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11670
Re: help requested using the find command
« Reply #5 on: May 04, 2013, 09:51:06 PM »
Hi aus9
This is what I get:
Code: [Select]
tc@box:~$ ls -al /mnt/sda3/home/
total 12
drwxr-xr-x  3 root root  4096 Dec 17  2011 ./
drwxr-xr-x  7 root root  4096 Dec 17  2011 ../
drwxr-sr-x 37 tc   staff 4096 May  4 00:38 tc/
tc@box:~$

aus9

  • Guest
Re: help requested using the find command
« Reply #6 on: May 04, 2013, 10:18:51 PM »
thanks its only others I need to fix up

mark as solved as I can live with my failed attempts in first post

aus9

  • Guest
Re: [SOLVED]help requested using the find command
« Reply #7 on: May 04, 2013, 10:26:33 PM »
Now to show a summary of how to create      rwx  r--  --T

Code: [Select]
cd /tmp
mkdir testz
chmod 740 testz
chmod o+t testz
ls -al (cull all but target)
drwxr----T   2 tc   staff     40 May  5 10:23 testz/

OR
mkdir testa
chmod 1740 testa
drwxr----T   2 tc   staff     40 May  5 10:28 testa/
« Last Edit: May 04, 2013, 10:29:28 PM by aus9 »