Tuesday, November 12, 2013

Linux tips

yum manager

The Yellowdog Updater, Modified (yum) is an open-source command-line package-management utility for Linux operating systems using the RPM Package Manager. Though yum has a command-line interface, several other tools provide graphical user interfaces to yum functionality. Yum allows automatic updates, package and dependency management, on RPM-based distributions. Yum works with software repositories (collections of packages), which can be accessed locally or over a network connection.

install: yum install mvno-paygw
find: yum search mvno-paygw
update: yum update mvno-paygw
info: yum info mvno-paygw  (information about package; what version is on repository)
check-update: Checks to see whether updates are available. If they are, yum displays their names, version and repository area.
provides: searches for which packages provide the requested dependency of file. This also takes wildcards for files. E.g. yum provides */ldapsearch

Process status

ps -ef | grep java

Change password for current user

passwd

Change password for user by using root account

sudo su
passwd someUser

Check if port 80 is open

netstat -tulpn | grep :80

Download web page

wget localhost:80/bugzilla

List hosts file

cat /etc/hosts

Copy file

cp [OPTION]... SOURCE... DIRECTORY
cp /wsdls/EID_Provision-V0.5.wsdl /var/opt/wsdls/EID_Provision-V0.5.wsdl

Delete file

rm fileName

Remove a directory and its contents without prompting you to make sure you want to delete each file in the directory.
rm -rf directory

Zip file

zip dest.zip sourceFile

The following command compresses the file archivefile1.txt and replaces it with the compressed version named "archivefile1.txt.bz2". bzip2 creates smaller files.
bzip2 archivefile1.txt

Read file/logs
[sudo] tail -100f /var/log/someLogFile.log

copy sourceFile.zip to another comp to user directory

 scp ./sourceFile.zip 10.200.0.133:./
(scp source_file_name username@destination_host:destination_folder)


Find 56952849307 that occured at 2015-02-06 10:2x in provisioning.log file
cat provisioning.log | grep "2015-02-06 10:2.*56952849307" | more
grep -A 3 "stringToFind" fileName   // show 3 lines after
grep -B 3 "stringToFind" fileName   // show 3 lines before
grep -C 3 "stringToFind" fileName   // show 3 lines around

Find 56952849307 in all files that begin with provisioning (e.g. provisioning.log.1)
ls provisioning* | xargs cat | grep 56952849307

Find USSD word in all provisioning.log files and show next 5 lines
cat /var/log/provisioning.log.* | grep MOVILB -A 5

grep all files in current directory for exact match:
grep -F "SIM card was deleted. MSISDN" *

dump tcp traffic to file
tcpdump -i any -w /tmp/test_001.pcap

ssh remote host identification has changed
ssh-keygen -R hostname

Change permission on folder
if needed switch to root user
$ sudo su
$ chmod -R 777 folderName

Ref:
15 Practical Grep Command Examples In Linux / UNIX

Unix Less Command: 10 Tips for Effective Navigation
How To Use Linux Screen


No comments:

Post a Comment