Posts Tagged ‘solaris command’

FIND FILES BETWEEN TIME FRAMES

November 13th, 2021, posted in Solaris
Share

Example 1:
You want to find files between specific time frame and move them to different directory. You can use the -newer or -newmt option with find command.

In this below example I am creating 2 dummy files with different timestamp and moving any files found between those time frames are moved to directory /var/tmp/Archive.

touch -t 201310040000 first
touch -t 201410040000 last
# find . -newer first ! -newer last -type f -exec mv {} /var/tmp/Archive;

Example 2:
In this example, I am listing files between Oct 04 2013 and Oct 04 2014.
Sed command is for replacing dot ‘.’ with blank space before the file name.

#find . -newermt “2013-10-04 00:00:00” ! -newermt “2014-10-04 00:00:00” | sed ‘s/.///g’|xargs ls -l


If you require more information or any questions on the above commands please comment below.

Reference: http://linux.about.com/od/commands/l/blcmdl1_find.htm

Share

REMOVE A FILE STARTING WITH A Dash “-“

September 26th, 2021, posted in Solaris
Share

ls |grep -i file
–file1

$ rm –file1
rm: illegal option — file1
usage: rm [-fiRr] file …

rm “–file1”
rm: illegal option — file1
usage: rm [-fiRr] file …

Solution:
$ rm ./–file1
$ ls|grep -i file

Share

SSH ERROR No Hostkey Alg

July 18th, 2021, posted in Solaris
Share

Do not ever change the file permissions of rsa and dsa keys. I was working on troubleshooting some ssh issue and I decided to give read permissions to everyone on file /etc/ssh/ssh_host_rsa_key and the next thing I know I cant login to the server via ssh.

#ssh testbox01
no hostkey alg

#ls -l /etc/ssh/ssh_host_rsa_key
-rw——-. 1 root ssh_keys   1679 Nov 25  2014 ssh_host_rsa_key

#ls -l /etc/ssh/ssh_host_dsa_key
-rw——-   1 root     root         668 Aug 20  2007 /etc/ssh/ssh_host_dsa_key

#ls -l /etc/ssh/ssh_host_rsa_key.pub
-rw-r–r–. 1 root root        382 Nov 25  2014 ssh_host_rsa_key.pub
#ls -l /etc/ssh/ssh_host_dsa_key.pub
-rw-r–r–. 1 root root        382 Nov 25  2014 ssh_host_dsa_key.pub
Make sure the permissions are set to 0600 for the private ssh keys and 0644 for public ssh keys(default public keys under /etc/ssh ends with an extension .pub)
Share