Wednesday, September 2, 2015

Truss command

There was issue with DHCP server, to find the root cause of the issue and find the resolution, we had to do following,

1. Run truss command
# truss -f -v all -r all -w all -o /var/tmp/dhcp.out -p $ALL_QIP_PIDs

2. List qip processes
# ps -ef|grep qip

3. Run snoop
# snoop -o /var/tmp/snoop.cap not port 22

4. reproduce the problem
5. kill both truss and snoop
6. restore the services

List files not owned by a particular user


Listing files that are not owned by Oracle user.

# cd /opt/oracle
# find . ! -user oracle -ls | more

for aix
# find . -type f -size +40960 -print | xargs ls -l | sort -nk 5 | tail -50




Script: Find files without group read permission and give read permission to group

#!/bin/bash
# find files without group read permission and assign group read permission
#
S_PATH=/tools/archive/data_archive/MHRD

# condition check the search path
if [ ! -d ${S_PATH} ]; then
echo "Error " Please check the search path. ${S_PATH} dir does not exist"
exit 1
fi

# search command
/usr/bin/find ${S_PATH} -type f ! -perm -040 -exec /usr/bin/chmod g+r {} \;
# EOF

Tuesday, September 1, 2015

Thursday, August 27, 2015

link might be good

https://quizlet.com/subject/redhat/

http://www.flashcardmachine.com/

Description of Symmetric and Asymmetric Encryption

Symmetric Encryption

Symmetric encryption is the oldest and best-known technique. A secret key, which can be a number, a word, or just a string of random letters, is applied to the text of a message to change the content in a particular way. This might be as simple as shifting each letter by a number of places in the alphabet. As long as both sender and recipient know the secret key, they can encrypt and decrypt all messages that use this key.

Symmetric encryption uses the identical key to both encrypt and decrypt the data.  Symmetric key algorithms are much faster computationally than asymmetric algorithms as the encryption process is less complicated.  The length of the key size is critical for the strength of the security.  NIST has recommendations on how long a key should be– in general, 160-512 bits.   There are inherent challenges with symmetric key encryption in that the key must somehow be managed.  Distributing a shared key is a major security risk.


Asymmetric Encryption

The problem with secret keys is exchanging them over the Internet or a large network while preventing them from falling into the wrong hands. Anyone who knows the secret key can decrypt the message. One answer is asymmetric encryption, in which there are two related keys--a key pair. A public key is made freely available to anyone who might want to send you a message. A second, private key is kept secret, so that only you know it.  So, asymmetric encryption uses two related keys (public and private) for data encryption and decryption, and takes away the security risk of key sharing. The private key is never exposed.

Any message (text, binary files, or documents) that are encrypted by using the public key can only be decrypted by applying the same algorithm, and using the matching private key. Any message that is encrypted by using the private key can only be decrypted by using the matching public key.

This means that you do not have to worry about passing public keys over the Internet (the keys are supposed to be public). A problem with asymmetric encryption, however, is that it is slower than symmetric encryption. It requires far more processing power to both encrypt and decrypt the content of the message.


Digital Certificates

To use asymmetric encryption, there must be a way for people to discover other public keys. The typical technique is to use digital certificates (also known simply as certificates). A certificate is a package of information that identifies a user or a server, and contains information such as the organization name, the organization that issued the certificate, the user's e-mail address and country, and the user's public key.

When a server and client require a secure encrypted communication, they send a query over the network to the other party, which sends back a copy of the certificate. The other party's public key can be extracted from the certificate. A certificate can also be used to uniquely identify the holder.

RHEL - Commands you should master

lp print

ls list

pwd Present Working Directory

cat Views file

more Displays text file one screen at a time

file Displays file type

less Displays file with scroll and search capability

date Displays or changes system date

system-config-date Opens a GUI tool to Display or change system date

passwd Changes password

id [username] Displays user and group information for specified username

su - username Switches user while keeping environmental variables

su username Switches user without environmental variables

su - Switches to root user

exit Exits su to original user

chage Sets password age limit

whoami Shows original user id logged in as

groups Shows group memberships for each username

history Shows commands entered since login

!# Enters command with command history number #

!A Enters last command with the first letter A

[partial command] TAB TAB Displays commands similar to partial command entered

bg Runs a process ID in the background

fg Runs a process ID in the foreground

ctrl Z Breaks or pauses a process

ctrl C Kills a process

jobs Shows jobs running on machine

ctrl-alt-f5 Switches to virtual console 5

ctrl-alt-f1 Returns to GUI from virtual console

virt-manager Opens a GUI tool for virtual machine manager

echo $PATH Displays path of commands used

echo $ Displays environmental variable value or prints script info to user screen

cd Changes directory

cp Copies files

ln Creates a hard link

ln -s Creates a symbolic link or alias

mv Moves a file

rm Removes a file or directory

touch Creates or updates access and modification times of a file

mkdir Creates a directory

rmdir Removes an empty directory

alias Creates a command alias in .bashrc file

reset Clears terminal log history and terminal window

clear Clears terminal window but not log

where is Locates executable command paths

locate Searches for a file path in nightly indexed file database

updatedb Creates or updates the indexed file database used by locate command

find Searches for a file in a directory hierarchy

system-release Displays RedHat Version information

nano Text editor and file creator

gedit Opens a GUI text editor

man Opens a manual page for a command

man -k Suggests manual page similar to text entered

makewhatis Updates man database after packet installation

pinfo Advanced lynx based viewer for commands info page or its manual page if one does not exist

firefox Opens a GUI web browser

sudo Allows a user to execute a command at another users access level

lpadmin Configures a printer

lp [filename] Prints filename to default printer

palimpsest Opens a GUI disk utility

fdisk Mbr disk partitioner

df -h Shows mapping of disk partitions

mount Mounts a directory as a partition

umount Unmounts a directory as a partition

pvcreate Creates a logical physical volume

pvdisplay Displays logical physical volumes

vgcreate Creates a volume group from physical volume physical extents

vgdisplay Displays volume groups

lvcreate Creates a logical volume made of physical extents

lvdisplay Displays logical volumes

mkfs Formats a partition and creates a filesystem

vgextend Extends a volume group to a new partition

resize2fs Extends a logical volume group filesystem

lsblk Displays overview of partitions and logical volumes

kill -l Displays a list of process signals

kill Sends a signal to a process

nice Runs a command with a modified niceness scheduling priority

renice Alters the niceness scheduling priority of a process

top Opens command line process manager

ps Displays processes running from current window

ps -e Displays every process running on system

du Displays disk usage

du -sh Displays total disk usage of all directorys under current directory

yum Yellowdog updater modified package manager

rpm Redhat package manager

Package manager that does not resolve dependencies Rpm package manager

Package manager that does resolve dependencies Yum package manager

createrepo Creates yum repository

system-config-network Opens a GUI for configuring network interfaces

arp Modify the system arp cache

ip Displays IP address and network information similar to ifconfig

ifconfig Displays IP address and network information similar to ip

route Displays or modifies routing table of system

iproute Second way to display routing table of system

netstat -r Display only routing table of system

host Simple DNS hostname or IP look up tool based on the same engine as DIG

nslookup Older DNS lookup tool that queries it's own DNS table before contacting a DNS server and then showing IP and Host as well as the lookup server

hostname Displays or nonpersistantly modifies hostname entry in /proc/sys/kernel/hostname

service network restart Restarts network services with new settings

dig In depth DNS lookup utility similar to host that gives entire DNS message

tail Displays last ten lines of a file

chsh Changes shell

chage Changes password aging similar to passwd-x or usermod

passwd -x Changes password aging similar to chage or usermod

usermod Changes user attributes

useradd Adds a user to passwd but will not assign a password

groupadd Adds a group to groups or directory

chown Changes user ownership of a file or directory

chmod Changes mode of a file

chgrp Changes group ownership of a file or directory

ssh Opens a secure shell terminal

scp Secure copies a file

rsync Syncs remote files to local files

ssh-keygen Generates, manages, and converts authentication keys for ssh

ssh-copy-id Installs ~/.ssh/id_rsa.pub in a remote machines ~/.ssh/authorized_keys file

file-roller Opens a GUI archive manager

chkconfig Displays or modifies services run at boot

vncpasswd Sets your VNC password on the VNC server

vncviewer Opens a GUI VNC window

getsebool Displays SE Linux variables

iptables Sets up, maintains, and inspects the tables of IP packet filter rules in the linux kernel (firewalls)

seinfo Queries SE linux policy

getenforce Displays SE linux status

setenforce Changes SE linux status

restorecon Restores SE linux file context based on dir it is in

chcon Changes SE linux file context

tune2fs Displays or modifies tunable filesystem parameters on ext filesystems

blkid Displays or modifies block id attributes of disks

setfacl Sets file access control lists

swapon Enables a swap partition

swapoff Disables a swap partition

uname -r Displays currently running kernel

cat /proc/cmdline Displays arguments passed to kernel at boot

init Sets init runlevel for next boot

runlevel Displays previous and current system runlevel

umask Sets file mode creation mask for files and directories

tar Creates a tar file

gpg Encryption and signing tool allowing private key use to run scripts

service Displays status, starts, stops, or restarts a system init script

ftp Opens text based ftp client

sealert Opens a GUI SE linux browser and troubleshooter

grep flags /proc/cpuinfo Displays processor stats

virsh Creates a virtual machine

lvrename Renames a logical volume

lvremove Removes a logical volume

ctrl - Decreases font size

ctrl + Increases font size

vim Opens a text editor similar to vi

squid Proxy caching server

partprobe Informs kernel of partition table changes to nonprimary partions

kpartx Creates device maps from partition tables

w Displays currently logged in users

last Displays last lines of a file or log

makewhatis Creates or renews man -k database

wc Displays word count on a file

sort Sorts lines in a file for output

unique Displays non adjacent unique lines in a file

tee Reads from standard input and writes to a file

e2label Changes label on ext partition

cryptsetup Encrypts a partition

reboot Restarts system

mkswap Create a linux swap area in a file or partition

lvm Open text based logical volume manager

info Displays Info pages of a command

dmsetup Low level logical volume manager

vgreduce Shrinks a volume group by removing a physical volume from it.

fsck Checks and repairs the health of an unmounted filesystem

pvs Checks available extents in a physical volume

pvmove Moves data off a physical volume that is to be removed.

lvreduce Shrinks a logical volume to a defined size

lvextend Extends a logical volume to a defined size or by a defined amount

showmount Displays the mount information for an NFS server

smbclient Samba ftp client to access SMB/CIFS resources on servers

service autofs reload Reinitializes autofs after updating /etc/auto.master

userdel Removes a user from /etc/passwd file

groupdel Removes a group from /etc/groups file

vipw Locks the passwd file and opens it for editing user information

vigr Locks the groups file and opens it for editing group information

pwconv Syncs the /etc/shadow and /etc/passwd files

pwchk Checks the /etc/passwd file for errors

automount manages autofs mount points

system-config-users Opens a GUI tool for managing users and groups

autoconfig Opens a TUI interface for managing NIS, LDAP, Kerberos 5, and SMB, by editing the /etc/sysconfig/network, /etc/passwd, and /etc/shadow files.

system-config-authentication Opens a GUI tool for managing NIS, LDAP, Kerberos 5, and SMB, by editing the /etc/sysconfig/network, /etc/passwd, and /etc/shadow files.

getent Searches a given database file like passwd, group, aliases, shadow, etc.. for a defined term and returns matching entries

getfacl Displays file acl for provided file path

grpconv Syncs /etc/group and /etc/gshadow files

newgrp Changes group id to a named group. Similar su - command for changing users.

gpasswd Sets group password in /etc/gshadow

wget Non-Interactive file downloader that allows a user to retrieve a file while not logged in. Designed to work over slow or unstable network connections.

ps -eZ Displays SE linux information for processes

semanage fcontext Displays SE linux defaults used by restorecon

setsebool Sets specific SE linux rules on or off

lsof Displays list of files opened by system

nc Opens netcat utility for troubleshooting tcp/udp connections

service rsyslog restart Restarts log server after changes to rsyslog.conf

logger Sends a test message to the log server

logwatch Monitors logs and emails a summary to root

killall Kills all processes with a specific name

crontab Configures cron files in the /var/spool/ directory used by the crond process

anacron Similar to cron, it runs commands listed in the /etc/anacrontab file based on date it was last run, so cron commands are not missed in the event of a system being shut down.

dmesg Displays boot messages from the kernel ring buffer /proc/ksmsg

sysctl Configures kernel parameters for next boot cycle

modinfo Displays information about a kernel module

lsmod Displays what modules are loaded by kernel

modprobe Adds or removes modules from the kernel