To get the list of files with details inside a folder:
ls -l OR ll
To know the count of files inside a folder:
ls -l | wc -l
To get the count of files (whose name starts with 'FolderCreation' inside a folder):
ls -l FolderCreation20180523* | wc -l
To get the count of PDF files (which are created/modified today itself i.e 0 days before):
find ./ -type f -mtime 0 | grep "PDF" | wc -l
To get the count of PDF files (which are created/modified a day before i.e 1 day before):
find ./ -type f -mtime 1 | grep "PDF" | wc -l
To get the count of xml files (which are created/modified a day before i.e 1 day before):
find ./ -type f -mtime 1 | grep "xml" | wc -l
To move the files (created/modified) a day before, into a folder named 'FileUpload' located in parallel to the current folder you are into:
find ./ -type f -mtime 1 -exec mv {} ../FileUpload \;
To get the list of PDF files whose name starts with 'AD_' and contains '_676' in its name:
ls -l AD_*_676*.PDF | wc -l
To search for content in all files in linux:
grep -rnw . -e 'content' // r - recursive , n - line number, w - for match the whole word , dot - searching on current path
To simple search files recursively:
find . -name "filename*"
find . -name "filename" //if you are sure about the exact file name
To change owner of file:
chown <new_owner_name> <filename>
To change group of file:
chown :<new_group_name> <filename>
ex: chown :Domain\ Users abc.pdf //this is because my group 'Domain Users' contain space
To change both owner and group of file:
chown <new_owner_name>:<new_group_name> <filename>
Courtesy : https://www.thegeekstuff.com/2012/06/chown-example...
To copy a line in vim editor:
yy
To copy multiple lines (ex: 4 lines from current line) in vim:
yy4yy
To paste:
p
To delete a line in vim:
dd
To send/test email by specifying smtp server name:
mailx -S smtp="smtp.xxx.xxxx.com" -r "admin@alfresco.com" -s "Test" -v -t "firstname.lastname@abc.com" "Test"
Sending email (static) without smtp server (default smtp server) with echo/output:
echo "test" | mailx -S -r "admin@alfresco.com" -s "Test" -v "xxx.yyyy@abc.com"
Sending email (dynamic) with echo/output:
echo "$BODY" | mailx -S smtp="smtp.xxx.xxxx.com" -r "admin@$(hostname)" -s "$SUBJECT" -v "xxxxyyyy@abc.com"
Setting cron expression (crontab) to execute at fixed schedule:
1) Command prompt [...]$: crontab -l //this will show you list of already configured/scheduled cron expressions
2) Command prompt [...]$: crontab -e //this will allow you to edit/add your own cron expression to the list. Example:
#Crontab for checking a script every 2 hours
0 2 * * * /opt/services/test-service.sh
-----------------------------------------------------------------------------------------------------------
SCP command to copy file(s) from one server to another:
a) From QA to DEV:
Login to DEV server (go to path example: /opt/alfresco5/tomcat/webapps/).
Now to copy ABC.war from QA server to DEV current path:
scp alfresco@qaalfserver1.xx.xxx.com:/opt/alfresco/tomcat/webapps/ABC.war .
b) From DEV to QA:
scp alfresco@devalfserver1.xx.com:/opt/alfresco5/amps/abc.amp .
-----------------------------------------------------------------------------------------------------------
Install AMP(s) using alfresco-mmt.jar command: (navigate to /opt/alfresco/bin/ - before firing below commands; and make sure alfresco-mmt.jar exists at this location)
a) Installing repo amp into alfresco.war:
java -jar alfresco-mmt.jar install APP_NAME-1.0.amp alfresco.war
b) Installing share amp into share.war:
java -jar alfresco-mmt.jar install APP_NAME_SHARE-1.0.amp share.war
c) To see the list of AMPs already installed:
java -jar alfresco-mmt.jar list alfresco.war
java -jar alfresco-mmt.jar list share.war
d) To uninstall amp(s) from alfresco.war or share.war (current dir: /opt/alfresco/)
java -jar bin/alfresco-mmt.jar uninstall xxx-share-amp tomcat/webapps/share.war
java -jar bin/alfresco-mmt.jar uninstall xxx-repo-amp tomcat/webapps/alfresco.war
e) To install amp(s) into alfresco.war or share.war (current dir: /opt/alfresco/)
NOTE: Appending '-force' at the end is optional, append it only if required.
java -jar bin/alfresco-mmt.jar install amps/xxx-repo.amp tomcat/webapps/alfresco.war -force
java -jar bin/alfresco-mmt.jar install amps_share/xxx-share-1.0.amp tomcat/webapps/share.war -force
-----------------------------------------------------------------------------------------------------------
Copy command:
a) Copy recursively entire folder contents from one to another location on same server:
cp -r keystore /data/alf_data/ABC/
b) Normal file(s) copy:
cp /opt/app/alfresco5/amps/* . //this will copy all files under amps folder to current loc
cp /opt/app/alfresco5/amps/xxx-repo.amp . //this will copy xxx-repo.amp under amps folder to current loc
--------------------------------------------------------------------------------------------------
To install httpd / apache service:
sudo yum install -y httpd
-------------------------------------------------------------------------------------------------
Test email from command prompt linux:
$ echo "something" | mailx -s "subject" sanket.mehta@ge.com
echo "Body" | mailx -r "sanket.mehta@ge.com" -s "SUBJECT" "sanket.mehta@ge.com"
sudo mailx -S smtp="smtp.*****.com" -r "sanket.mehta@ge.com" -s "SUBJECT" -v "sanket.mehta@ge.com"
sudo mail -S smtp="smtp.*****.com" -r "sanket.mehta@ge.com" -s "SUBJECT" -v "sanket.mehta@ge.com"
sudo mail -S smtp=smtp.*****.com -r sanket.mehta@ge.com -s SUBJEC -v sanket.mehta@ge.com
---------------------------------------------------------------------------------------------------
source ~/.bash_profile //to set path,java home when jar is not running
grep -r "214***30" /opt/****Files/ //to search for content inside the files on the mentioned path
grep -r "J-18-007442" /opt/***Files/
ps aux --sort -rss //list out the processes in ascending order which occupies high memory
grep -r "any_content" /opt/***Files/archived/2019-02-15 | wc -l //to get count of files
--------------------------------------------------------------------------------------------
For SSH Key:
ssh -i private_openssh.pem SSO@pwnxxxxx.xxxx.com
cp /home/SSO/private_openssh.ppk .
ls -l OR ll
To know the count of files inside a folder:
ls -l | wc -l
To get the count of files (whose name starts with 'FolderCreation' inside a folder):
ls -l FolderCreation20180523* | wc -l
To get the count of PDF files (which are created/modified today itself i.e 0 days before):
find ./ -type f -mtime 0 | grep "PDF" | wc -l
To get the count of PDF files (which are created/modified a day before i.e 1 day before):
find ./ -type f -mtime 1 | grep "PDF" | wc -l
To get the count of xml files (which are created/modified a day before i.e 1 day before):
find ./ -type f -mtime 1 | grep "xml" | wc -l
To move the files (created/modified) a day before, into a folder named 'FileUpload' located in parallel to the current folder you are into:
find ./ -type f -mtime 1 -exec mv {} ../FileUpload \;
To get the list of PDF files whose name starts with 'AD_' and contains '_676' in its name:
ls -l AD_*_676*.PDF | wc -l
To search for content in all files in linux:
grep -rnw . -e 'content' // r - recursive , n - line number, w - for match the whole word , dot - searching on current path
To simple search files recursively:
find . -name "filename*"
find . -name "filename" //if you are sure about the exact file name
To change owner of file:
chown <new_owner_name> <filename>
To change group of file:
chown :<new_group_name> <filename>
ex: chown :Domain\ Users abc.pdf //this is because my group 'Domain Users' contain space
To change both owner and group of file:
chown <new_owner_name>:<new_group_name> <filename>
Courtesy : https://www.thegeekstuff.com/2012/06/chown-example...
To copy a line in vim editor:
yy
To copy multiple lines (ex: 4 lines from current line) in vim:
yy4yy
To paste:
p
To delete a line in vim:
dd
To send/test email by specifying smtp server name:
mailx -S smtp="smtp.xxx.xxxx.com" -r "admin@alfresco.com" -s "Test" -v -t "firstname.lastname@abc.com" "Test"
Sending email (static) without smtp server (default smtp server) with echo/output:
echo "test" | mailx -S -r "admin@alfresco.com" -s "Test" -v "xxx.yyyy@abc.com"
Sending email (dynamic) with echo/output:
echo "$BODY" | mailx -S smtp="smtp.xxx.xxxx.com" -r "admin@$(hostname)" -s "$SUBJECT" -v "xxxxyyyy@abc.com"
Setting cron expression (crontab) to execute at fixed schedule:
1) Command prompt [...]$: crontab -l //this will show you list of already configured/scheduled cron expressions
2) Command prompt [...]$: crontab -e //this will allow you to edit/add your own cron expression to the list. Example:
#Crontab for checking a script every 2 hours
0 2 * * * /opt/services/test-service.sh
-----------------------------------------------------------------------------------------------------------
SCP command to copy file(s) from one server to another:
a) From QA to DEV:
Login to DEV server (go to path example: /opt/alfresco5/tomcat/webapps/).
Now to copy ABC.war from QA server to DEV current path:
scp alfresco@qaalfserver1.xx.xxx.com:/opt/alfresco/tomcat/webapps/ABC.war .
b) From DEV to QA:
scp alfresco@devalfserver1.xx.com:/opt/alfresco5/amps/abc.amp .
-----------------------------------------------------------------------------------------------------------
Install AMP(s) using alfresco-mmt.jar command: (navigate to /opt/alfresco/bin/ - before firing below commands; and make sure alfresco-mmt.jar exists at this location)
a) Installing repo amp into alfresco.war:
java -jar alfresco-mmt.jar install APP_NAME-1.0.amp alfresco.war
b) Installing share amp into share.war:
java -jar alfresco-mmt.jar install APP_NAME_SHARE-1.0.amp share.war
c) To see the list of AMPs already installed:
java -jar alfresco-mmt.jar list alfresco.war
java -jar alfresco-mmt.jar list share.war
d) To uninstall amp(s) from alfresco.war or share.war (current dir: /opt/alfresco/)
java -jar bin/alfresco-mmt.jar uninstall xxx-share-amp tomcat/webapps/share.war
java -jar bin/alfresco-mmt.jar uninstall xxx-repo-amp tomcat/webapps/alfresco.war
e) To install amp(s) into alfresco.war or share.war (current dir: /opt/alfresco/)
NOTE: Appending '-force' at the end is optional, append it only if required.
java -jar bin/alfresco-mmt.jar install amps/xxx-repo.amp tomcat/webapps/alfresco.war -force
java -jar bin/alfresco-mmt.jar install amps_share/xxx-share-1.0.amp tomcat/webapps/share.war -force
-----------------------------------------------------------------------------------------------------------
Copy command:
a) Copy recursively entire folder contents from one to another location on same server:
cp -r keystore /data/alf_data/ABC/
b) Normal file(s) copy:
cp /opt/app/alfresco5/amps/* . //this will copy all files under amps folder to current loc
cp /opt/app/alfresco5/amps/xxx-repo.amp . //this will copy xxx-repo.amp under amps folder to current loc
--------------------------------------------------------------------------------------------------
To install httpd / apache service:
sudo yum install -y httpd
-------------------------------------------------------------------------------------------------
Test email from command prompt linux:
$ echo "something" | mailx -s "subject" sanket.mehta@ge.com
echo "Body" | mailx -r "sanket.mehta@ge.com" -s "SUBJECT" "sanket.mehta@ge.com"
sudo mailx -S smtp="smtp.*****.com" -r "sanket.mehta@ge.com" -s "SUBJECT" -v "sanket.mehta@ge.com"
sudo mail -S smtp="smtp.*****.com" -r "sanket.mehta@ge.com" -s "SUBJECT" -v "sanket.mehta@ge.com"
sudo mail -S smtp=smtp.*****.com -r sanket.mehta@ge.com -s SUBJEC -v sanket.mehta@ge.com
---------------------------------------------------------------------------------------------------
source ~/.bash_profile //to set path,java home when jar is not running
grep -r "214***30" /opt/****Files/ //to search for content inside the files on the mentioned path
grep -r "J-18-007442" /opt/***Files/
ps aux --sort -rss //list out the processes in ascending order which occupies high memory
grep -r "any_content" /opt/***Files/archived/2019-02-15 | wc -l //to get count of files
--------------------------------------------------------------------------------------------
For SSH Key:
ssh -i private_openssh.pem SSO@pwnxxxxx.xxxx.com
cp /home/SSO/private_openssh.ppk .
------------------------------------------------------------------------------------
For checking port opened or not with telnet or nmap command:
NMAP examples for checking connectivity/opened port between nodes/instances:
Ex: ARender node to 5 Repo nodes:
nmap -p 8761,8080 -Pn <Repo1_IP> <Repo2_IP> <Repo3_IP> <Repo4_IP> <Repo5_IP>
Tracker OR Sched OR Repo OR Integ node to 1 Transformation node:
nmap -p 61616,8090,8099,8161,8095,8100 -Pn <TNF_IP>
Tracker OR Sched OR Repo OR Integ node to 1 AMQ:
nmap -p 61616 -Pn <AMQ_NODE_IP>
Tracker OR Sched OR Repo OR Integ node to 12 Solr shards :
nmap -p 8983 -Pn <Shard0_IP> <Shard2_IP> ... <Shard11_IP>
Tracker OR Sched OR Repo OR Integ node OR Solr shard to RDS:
nmap -p 1521 -Pn <RDS_HOSTNAME>
Tracker OR Sched OR Repo OR Integ node to ARender LB:
nmap -p 80 -Pn i<ARENDER_LB>
Tracker OR Sched OR Repo OR Integ node to S3:
aws s3 ls
TNF to 5 Repos:
nmap -p 8095,8080,8100,61616 -Pn <Repo1_IP> <Repo2_IP> <Repo3_IP> <Repo4_IP> <Repo5_IP>
TNF to 1 AMQ. node:
nmap -p 61616 -Pn <AMQ_IP>
Solr Shard to 4 Trackers:
nmap -p 8080 -Pn <TRK1_IP> <TRK2_IP> <TRK3_IP> <TRK4_IP>
Solr Shard to 5 Repos:
nmap -p 8080 -Pn <Repo1_IP> <Repo2_IP> <Repo3_IP> <Repo4_IP> <Repo5_IP>
Repo, Tracker, Sched, Integ. node to Solr LB:
nmap -p 80 -Pn <SOLR_LB>
Check clustering port 5701 is opened between repo nodes:
nmap -p 5701 -Pn <Repo1_IP> <Repo2_IP> <Repo3_IP> <Repo4_IP> <Repo5_IP>
For telnet:
telnet IP_ADDRESS PORT_NAME
example: telnet IP_ADDRESS 8983
-------------------------------------------------------------------------------
Find an occurence of a string within a file:
grep "rds_host:1521:sid" alfresco-global.properties
Replace all occurences of a string within a file:
sed -i 's/rds_host:1521:sid/rds_new_host:1521:new_sid/g' alfresco-global.properties
Replace all IP occurences with other IP in a file:
Syntax: sed -i 's/source_ip_to_find/new_ip_to_replace_old_ip/g' alfresco-global.properties
Example: sed -i 's/172.50.2.249/172.60.2.246/g' alfresco-global.properties
Replace all occurences by taking backup of original file:
sed -i.bak 's/rds_host:1521:sid/rds_new_host:1521:new_sid/g' alfresco-global.properties
-------------------------------------------------------------------------
zip and unzip commands:
To zip a folder recursively:
zip -r filename.zip directory
To unzip a zip file into a folder:
unzip filename.zip -d /opt
OR
If you want to unzip at current location or current dir only, then :
unzip filename.zip -d .
OR
unzip filename.zip
------------------------------------------------------------------------
rsync command:
Syntax: rsync src_filename username@IP_ADDRESS:/destination_path/
Example: rsync data.zip admin@172.xxx.xx.xxx:/opt/
Creating symlink of a jdk path to another jdk path:
ln -s /software/java/jdk-11.0.2/bin/java /usr/bin/java
Creating symlink of a libreoffice path to another path:
ln -s /opt/libreoffice6.3/program/soffice /usr/bin/java
Set envt:
set-environment PATH=/sbin:/bin:/usr/sbin:/usr/bin:/software/java/jdk-11.0.2/bin:/opt/libreoffice6.3/program:/usr/lib:/usr/local/lib
No comments:
Post a Comment