Showing posts with label UNIX/Linux. Show all posts
Showing posts with label UNIX/Linux. Show all posts

Saturday, December 20, 2008

How To Disable Telnet For Linux User

If you need to disable the telnet function for a particular UNIX/Linux user, it can be done by editing the /etc/passwd file and replace the shell (say /bin/bash) for that user’s entry with something else (say say /dev/null).

If it doesn’t work, then do these:-

- Login as the user.
- Edit the .profile (with vi editor) and add in the last line “exit”.
- Save the .profile.

With that, if the user tries to do a telnet, he will be automatically kicked out.

 

Wednesday, October 8, 2008

Find command in Linux

I suppose the “find” command is properly the most useful utility in UNIX/Linux.

The following are a few examples showing how to perform some common tasks using the “find” tool. I will add more as time goes on.

Basic syntax: find pathname... expression

#If you want to find files that are 7 days old, use the -mtime option
find . -mtime 7 -print
(Assuming today is 23-Dec, the command will show the files that are only dated 16-Dec.)

#An alternate way is to specify the range of periods
find . -mtime +6 -mtime -8 -print
find . -mtime +6 -mtime -8 -exec ls -lt {} \;

#Find files based on 7 days ago (atime means last accessed time)
find / -atime 7 -ls

#List old files and delete them (mtime means last modified/creation time of a file)
find -mtime +60 -exec rm -f {} \;

#Find core files in the directory and remove them
find . -name "core" -exec rm -f {} \;

Note:-
When using with “-exec” command, it should be used together with {} and ; (semicolon), where {} is used as a variable whose name is the file “find” found. As for ; (semicolon), it represents the end of command which must be punctuated by a quoted or escaped ; (semicolon).

*** df -h (human readable)

du -sh * | sort –nr

du -hsx * | sort -rh | head -10