0% found this document useful (0 votes)
2 views8 pages

Linux All Find Command

The document contains a series of Linux command line operations performed by the root user, including user creation, file and directory searches, file size checks, and file manipulations. It demonstrates the use of commands like 'useradd', 'find', 'fallocate', and 'cp' to manage users and files. Additionally, it includes error messages encountered during the operations, indicating issues such as attempting to overwrite existing files or directories.

Uploaded by

jobaer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views8 pages

Linux All Find Command

The document contains a series of Linux command line operations performed by the root user, including user creation, file and directory searches, file size checks, and file manipulations. It demonstrates the use of commands like 'useradd', 'find', 'fallocate', and 'cp' to manage users and files. Additionally, it includes error messages encountered during the operations, indicating issues such as attempting to overwrite existing files or directories.

Uploaded by

jobaer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

[root@localhost ~]# useradd alex

[root@localhost ~]# find / -name alex

/home/alex

/var/spool/mail/alex

[root@localhost ~]# find / -name alex -type f

/var/spool/mail/alex

[root@localhost ~]# find / -name alex -type d

/home/alex

[root@localhost ~]# touch /root/ Alex

[root@localhost ~]# find / -iname alex

/home/alex

/root/Alex

/var/spool/mail/alex

[root@localhost ~]# find / -perm 777

[root@localhost ~]# find / -name shadow

/etc/shadow

[root@localhost ~]# find / -name shadow -exec ls -l {} \;

----------. 1 root root 1841 Oct 22 08:17 /etc/shadow

[root@localhost ~]#
[root@localhost ~]# fallocate file -l 20M

[root@localhost ~]# ll

drwxr-xr-x. 2 root root 6 Oct 15 08:52 Desktop

drwxr-xr-x. 2 root root 6 Oct 15 08:52 Documents

drwxr-xr-x. 2 root root 6 Oct 15 08:52 Downloads

-rw-r--r--. 1 root root 20971520 Oct 22 08:39 file

-rwxrwxrwx. 1 root root 0 Oct 17 08:54 file1

drwxr-xr-x. 2 root root 20 Oct 19 08:31 main

[root@localhost ~]# ll -h /root/

total 21M

-rwxrwxrwx. 1 root root 0 Oct 22 08:23 Alex

-rw-------. 1 root root 1.2K May 31 10:24 anaconda-ks.cfg

drwxr-xr-x. 2 root root 24 Oct 19 11:16 archived

drwxr-xr-x. 2 root root 6 Oct 19 08:22 compressed

drwxr-xr-x. 2 root root 6 Oct 19 08:22 decompressed

drwxr-xr-x. 2 root root 6 Oct 15 08:52 Desktop

drwxr-xr-x. 2 root root 6 Oct 15 08:52 Documents

drwxr-xr-x. 2 root root 6 Oct 15 08:52 Downloads

-rw-r--r--. 1 root root 20M Oct 22 08:39 file

-rwxrwxrwx. 1 root root 0 Oct 17 08:54 file1

[root@localhost ~]# du -sh file

20M file

[root@localhost ~]# find / -size 200M


find: ‘/proc/2625/task/2625/fd/5’: No such file or directory

find: ‘/proc/2625/task/2625/fdinfo/5’: No such file or directory

find: ‘/proc/2625/fd/6’: No such file or directory

find: ‘/proc/2625/fdinfo/6’: No such file or directory

[root@localhost ~]# find / -size 20M

find: ‘/proc/2630/task/2630/fd/5’: No such file or directory

find: ‘/proc/2630/task/2630/fdinfo/5’: No such file or directory

find: ‘/proc/2630/fd/6’: No such file or directory

find: ‘/proc/2630/fdinfo/6’: No such file or directory

/run/media/root/RHEL-9-0-0-BaseOS-x86_64/AppStream/Packages/docbook5-style-xsl-1.79.2-
13.el9.noarch.rpm

/run/media/root/RHEL-9-0-0-BaseOS-x86_64/AppStream/Packages/gimp-2.99.8-2.el9_0.1.x86_64.rpm

/run/media/root/RHEL-9-0-0-BaseOS-x86_64/AppStream/Packages/kernel-debug-devel-5.14.0-
70.22.1.el9_0.x86_64.rpm

/run/media/root/RHEL-9-0-0-BaseOS-x86_64/AppStream/Packages/kernel-devel-5.14.0-
70.22.1.el9_0.x86_64.rpm

/root/file

/usr/share/fonts/google-noto-cjk/NotoSansCJK-Bold.ttc

/usr/share/fonts/google-noto-cjk/NotoSansCJK-Regular.ttc

[root@localhost ~]# find / -size +20M

[root@localhost ~]# mkdir fi

[root@localhost ~]# cd fi

[root@localhost ~]# useradd brain

[root@localhost ~]#

[root@localhost fi]# fallocate file -l 30M


[root@localhost fi]# fallocate file1 -l 20M

[root@localhost fi]# fallocate file2 -l 10M

[root@localhost fi]# ll

total 61440

-rw-r--r--. 1 root root 31457280 Oct 22 08:51 file

-rw-r--r--. 1 root root 20971520 Oct 22 08:53 file1

-rw-r--r--. 1 root root 10485760 Oct 22 08:53 file2

[root@localhost ~]# find fi/ -name file1

fi/file1

[root@localhost ~]# find fi/ -size 20M

fi/file1

[root@localhost ~]# find fi/ -size -20M

fi/

fi/file2

[root@localhost ~]# cd fi/

[root@localhost fi]# fallocate file4 -l 25M

[root@localhost fi]# ll

total 87040

-rw-r--r--. 1 root root 31457280 Oct 22 09:03 file

-rw-r--r--. 1 root root 20971520 Oct 22 08:53 file1


-rw-r--r--. 1 root root 10485760 Oct 22 08:53 file2

-rw-r--r--. 1 root root 26214400 Oct 22 09:03 file4

[root@localhost fi]#

[root@localhost fi]# cd

[root@localhost ~]# find fi/ -size +20M -size -30M

fi/file4

[root@localhost ~]# ll -h fi/file4

-rw-r--r--. 1 root root 25M Oct 22 09:03 fi/file4

[root@localhost ~]#

[root@localhost ~]# du -sh fi/file4

25M fi/file4

[root@localhost ~]#

[root@localhost ~]# useradd brain

[root@localhost ~]#

[root@localhost ~]# find / -user brain

/home/brain

/home/brain/.mozilla

/home/brain/.mozilla/extensions

/home/brain/.mozilla/plugins

/home/brain/.bash_logout

/home/brain/.bash_profile

/home/brain/.bashrc

find: ‘/proc/34574/task/34574/fd/5’: No such file or directory


find: ‘/proc/34574/task/34574/fdinfo/5’: No such file or directory

find: ‘/proc/34574/fd/6’: No such file or directory

find: ‘/proc/34574/fdinfo/6’: No such file or directory

/var/spool/mail/brain

[root@localhost ~]#

[root@localhost ~]# find / -user brain -exec ls -l {} \;

total 0

total 0

drwxr-xr-x. 2 brain brain 6 Feb 28 2022 extensions

drwxr-xr-x. 2 brain brain 6 Feb 28 2022 plugins

total 0

total 0

-rw-r--r--. 1 brain brain 18 Nov 5 2021 /home/brain/.bash_logout

-rw-r--r--. 1 brain brain 141 Nov 5 2021 /home/brain/.bash_profile

-rw-r--r--. 1 brain brain 492 Nov 5 2021 /home/brain/.bashrc

find: ‘/proc/34580/task/34580/fd/5’: No such file or directory

find: ‘/proc/34580/task/34580/fdinfo/5’: No such file or directory

find: ‘/proc/34580/fd/6’: No such file or directory

find: ‘/proc/34580/fdinfo/6’: No such file or directory

-rw-rw----. 1 brain mail 0 Jan 15 10:37 /var/spool/mail/brain

[root@localhost ~]#

[root@localhost ~]# mkdir /brain

[root@localhost ~]#

[root@localhost ~]# find / -user brain -exec cp -fvpr {} /root/brain/ \;

cp: cannot overwrite non-directory '/root/brain/brain' with directory '/home/brain'

'/home/brain/.bash_logout' -> '/root/brain/.bash_logout'


'/home/brain/.bash_profile' -> '/root/brain/.bash_profile'

'/home/brain/.bashrc' -> '/root/brain/.bashrc'

'/home/brain/brain' -> '/root/brain/brain'

find: ‘/proc/34691/task/34691/fd/5’: No such file or directory

find: ‘/proc/34691/task/34691/fdinfo/5’: No such file or directory

find: ‘/proc/34691/fd/6’: No such file or directory

find: ‘/proc/34691/fdinfo/6’: No such file or directory

cp: cannot overwrite non-directory '/root/brain/brain' with directory '/root/brain'

cp: '/root/brain/.bash_logout' and '/root/brain/.bash_logout' are the same file

cp: '/root/brain/.bash_profile' and '/root/brain/.bash_profile' are the same file

cp: '/root/brain/.bashrc' and '/root/brain/.bashrc' are the same file

cp: '/root/brain/brain' and '/root/brain/brain' are the same file

cp: '/root/brain/extensions' and '/root/brain/extensions' are the same file

cp: '/root/brain/.mozilla' and '/root/brain/.mozilla' are the same file

cp: '/root/brain/plugins' and '/root/brain/plugins' are the same file

'/var/spool/mail/brain' -> '/root/brain/brain'

=====================================================================================
==================

Question:

# Add a user alex

# Find everything named alex

# Find all file of alex

# Find all directory of alex

# Create a file /root/Alex

# Find everything of alex case ignoring


# Find everything with permission 777

# Find shadow

# Find shadow also show its ls -l

# Create a 20M file

# ll -h

# show file size of file

# Find all 200M file

# Find all 20M file

# Make a directory fi

# cd fi

# create file1,file2,file3= 30M,20Mand10M

# cd

# find file1 in fi folder

# Find 20M size file in fi folder

# Find file lower then 20M in fi folder

# cd fi

# Add a file 25M file4

# cd

# find lower then 30M and upper then 20M file in fi

# ll -h of fi/file4

# show file size of fi/file4

# add a user brain

# find all of user brain

# find all of user brain and ls -l

# make a directory /root/brain

# Find all files owned by user brain and put them into /root/brain.

You might also like