UNIX-1.7 Find Command


Make sure to subscribe to my channel for more videos on UNIX, Perl and SQL.
facebook: facebook.com/fuzicast
twitter: @fuzicast
youtube: youtube.com/yuejdesigner85

find . -iname ‘regex’ – find filenames that match regex, case insensitive
find . -mtime +2 – find files that were modified 2 days ago or older
find . -mtime -2 – find files that were modified within past 2 days
find . -ctime +2 – find files that were created 2 days or older
find . -atime +2 – find files that were accessed 2 days or older
find . -cmin +30 – find files that were created 30 minutes ago or older
find . -mmin +30 – find files that were modified 30 minutes ago or older
find . -empty – find empty files or directory
find . -executable – find files that are executable by user
find . -readable – find files that are readable by user
find . -writable – find files that are writable by user
find . -size filesize – find files that have specified filesize (c = byte, k = kb, M = Mb, G = Gb)
find . -type filetype – find by file type (d = directory, f = file, l = link)
find . -user username – find files owned by user
find . -group groupname – find files that belong to specific group
find . -name ‘regex’ -delete – remove files that match regex
find . -name ‘regex’ -exec command – execute command on files found
find . -name ‘regex’ -ok command – same as -exec, but prompts for user’s input

Advertisements

UNIX-1.6 grep, useradd, usermod commands


Make sure to subscribe to my channel for more videos on UNIX, Perl and SQL.
facebook: facebook.com/fuzicast
twitter: @fuzicast
youtube: youtube.com/yuejdesigner85

last -10 username – get last 10 logins of specific user
passwd – change password
diff -y file1 file2 – find differences between 2 files
grep ‘regex’ file – search for pattern
grep -i ‘regex’ file – case insensitive search
grep -P ‘regex’ file – full support of Perl regex
grep -e ‘regex1’ -e ‘regex2’ file – search for multiple patterns
grep -v ‘regex’ file – inverse of search pattern (return non-matching lines)
grep -n ‘regex’ file – display line number with search result
grep -B4 ‘regex’ file – also display 4 lines before match
watch -n5 command – executes command every 5 second
adduser username – add a new user
usermod username -d /home/newhome – change home for new user
usermod username -d /home/newhome -m – change and move home content to a new home
usermod username -e 2022-05-11 – set account expiration date
usermod username -g group_name – set user group name/id
usermod username -l new_username – change username for user
usermod username -p new_password – change password for user
usermod username -s shell_name – change default shell for user
sudo -u username -i – run future commands as another user