1) Curl Command to download the data from a internet site.
curl -k -O https://testserver.com.au/file.zip
1) Curl Command to download the data from a internet site.
curl -k -O https://testserver.com.au/file.zip
ESC + ! + wq -- This for saving the file
ESC + ! + q --This will abort current changes
CNTRL +Z also works for aborting the changes but it is not proper way to abort.
shift + G -- Will come to the end of the file
dd -- typing two times in vi editor will delete the enitre line.
d -- only one time d will delete the one letter
i or insert button will be used for insert option. By default vi editory will be in edit mode.
vi -R file.txt -- Opens the file.txt in read only mode
id userid
id -- Command
userid- any user login that need to check for their permission
id -Gn userid
id -- Command
Gn -- Group name
userid- any user login that need to check for their permissions
groups -- command will be used to check current user groups
cat /etc/passwd | cut -d: -f5
The above command gives all user details in Unix server.
finger -- Command
finger username -- This gives infromation about current user login name and home path and from which servers its connected.
chmod 775 filename
There are three 3 modes of permissions
find /var -xdev -type f -size +300000c -exec ls -al {} \; | sort -k5nr | head -50
The above command fetches the files from the mount point /var with files greater that 300000kb that included hidden files and then sort the files to retreive the 50 large files.
-type : There can be f (file) or d (directory)
ls : for listing files
sort : for sorting the order
head: for limiting the record after sorting
find command will be used to find the file in a folder or directory
find /var -type f -name bkp* -exec ls -al {} \; | sort -k5nre | head -50
The above command fetches first 50 the files that starts with bkp name
Similary find can used with most of the file operation commands
find /var -type f -name bkp* -exec chmod 775 {} \;
The above command changes permission of the all the files starts with bkp to rwxrwxr-x (775) .
find /var -type f -name bkp* -exec chmod 770 {} \;
The above command changes permission of the all the directories starts with bkp to rwxrwx--- (770) .
If the current user who executing the above command does not have permission then it will not change and will get permission denied error.
sed : sed command will be used for replacing the text
sed -e 's/orginal keyword/replacing keyword/g' inputfile.txt
example
--------
sed -e 's/abc/cda/g' inputfile.txt > newfile.txt
above command replace the text abc in the file inputfile.txt with cda and put into newfile.txt file.
For moving the file we use the mv command. When you use mv command the actual file will be moved. The permissions and file creation timestamp will not be changed it will be as original file.
mv filename1.txt filename2.txt
In the above command it will rename filename1.txt to filename2.txt
mv /opt/sw/ss/filename1.txt /opt/sw/filename1.txt
The above command will move file from /opt/sw/ss/ drirectory to /opt/sw/ directory.
To move the entire directory we can use mvdir command
1) uuencode filename.txt | mailx -s "filename details" -c abc@test.com -r noreply@test.com sender@test.com
2) mail -s "Test mail" abc@test.com < TestFile.txt
3) (echo "Hi All, \n Please find the attached details in the email \n Thanks \n Application Team"; uuencode File.txt attahedFile.txt) | mailx -s "File details" -c abc@test.com -r noreply@test.com sender@test.com
After connecting to the sftp server, basically we will perfrom two operations
a) Pulling the file from remote server. For this we will use the get command
get : get will fecth the file from remote directory and place it to the current directory into the local server.
get will have two parameters . First parameter is mandatory which remote filepath and second parameter local directory path. if we do not provide the second variable it will copy int present directory
i ) get /opt/sw/unix/Remote/Test.txt
ii) get /opt/sw/unix/Remote/Test.txt /opt/sw/unix/local/Test.txt
The above commands will copy only the file. What if you need to copy the entire directory from remote server to local server using sftp command, We have abiltiy to copy enitre directory using -r option.
i ) get -r /opt/sw/unix/Remote
ii) get -r /opt/sw/unix/Remote /opt/sw/unix/local
put : put will place the file in remote directory from the current directory into the local server.
put will have two parameters . First parameter is mandatory which filepath and second parameter remote directory path. if we do not provide the second variable it will copy into present directory in remote server
i ) put /opt/sw/unix/Remote/Test.txt
ii) put /opt/sw/unix/Remote/Test.txt /opt/sw/unix/local.Test.txt
The above commands will place only the file. What if you need to place the entire directory from local server to remote server using sftp command, We have abiltiy to place enitre directory using -r option.
i ) put -r /opt/sw/unix/local
ii) put -r /opt/sw/unix/local/ /opt/sw/unix/remote/
Above will copy the local directory