Sei sulla pagina 1di 13

pkill -9 java to kill the other java process running.

ps -ef | grep java | wc l This count the java or Jboss or we can give any search Process running count.

scp -p psl-ds.xml root@jaz01cnc:/home/web/backup/ Going to that server wbbh001cnc path type this
command & copy the file to the jaz01cnc to the path :/home/web/backup/

mv shiva.txt shiva123.txt if you're already within file path use this rename command.

tail -f /var/log/httpd/access_log To check the access logs to ensure 200's for requests

yes | cp -r /var/www/html/* /home/web/backup/ while replacing Its consider Yes no need to type y.

rm file Deleting the file

touch shiva.txt create the text file name of the file shiva.

rm -r dir Deleting the directory

rm -f file Force to remove the file

rm -rf data/ tmp/ work/ Delete the folder Data, Tmp, Work

rm -rf dir Force to remove the directory dir

cp file1 file2 Copy the contents of file1 to file2

cp -r dir1 dir2 Copy dir1 to dir2;create dir2 if not present

mv file1 file2 Rename or move file1 to file2,if file2 is an existing directory

whoami Who you are logged in as.

finger user Display information about user.

ifconfig to check the ip address (View all the interfaces along with status)
iwconfig To gain information about the wireless adapters on your system.
nslookup wber001cnc To known the server IP.
free m check the memory status in Megabyte.(Total, used, free, shared, buffers, cached)
free g check the memory status value in Gigabytes.
df Show the disk usage

du Show directory Disk space usage

df -h Displays output in human readable form. i.e size will be displayed in GBs
du -h file1.php Displays the storage capacity of file1.php (Ans eg:- 8.0K file1.php)
du -s images Displays the total disk space used by the specified directory. (Ans Eg:- 1544 images)
ps ux To check all Process status we are using this command.
Pidof firefox Command checks the process status number of winamp. Then Type ps 3691
ps 3691 3691 is firefox process value number, this command show current running status.
Kill 3691 use this command to kill the process running 3691 that is firefox.
history -d 997 In History line number example line 997 means it will be deleted.
killall proc Kill all the process named proc
pkill pattern Will kill all processes matching the pattern
bg List stopped or background jobs, resume a stopped job in the background
fg Brings the most recent job to foreground
fg n Brings job n to the foreground
pwd (Present working Directory) To know which directory we are working.
cd ~ to return to home directory
cd / to move to root directory
cd .. Move one level up.
ps To display the currently working processes
/home/user/downloads in Linux (Eg: - c:\Documents & setting\Shiva\download)
Ctrl + Alt + T To launch the Terminal from the dashboard.
ls command display files in the current directory(Directory in Blue colour & File in White)
ls R show the Listing subdirectories/files
ls al Display File types& access, Memory Block,Owner of file Size, Date& Time, File&Directory.
ls a To View the Hidden file start with .
ls lrt | more List files by date. See also newest and find_mm_yyyy.
Cat > file1 create a new file & Press the Control D.
cat filename Displays the file content.
cat file file2 > file3 Joins two files File1, File2, & Stores the output in a File3.
mkdir songs Create the directory or Folder (Songs)
sudo command Give the super user Access. And it changes from $ to # Promote.
mv test test1 Rename the file from test to Test1.
mkdir songs creates a new Directory (Folder) Song in present working folder or directory.
mkdir /tmp/music Create the Music directory in TEMP Directory (folder).
man <Command> Gives us help information on command
history Give the details of the command use d before.
history -d $num eg:- History d$1005 (display list of commands in your history. Find the
number next to the one you want to delete and run)

ps -A |grep java To get the process id of that java process running.
kill -9 PID Process ID (PID) of that process whom you want to kill
cat shiva | less commands are used for dividing a long file into readable bits. Ctrl + Q to end
cat shiva | pg Used for dividing a long file into readable bits Press enter to page by page.
cat shiva | more Used for dividing a long file into readable bits Page by Page Press Enter.
cat shiva | grep -i a To search file starting with a in the Filename Directory(apple, ant)
cat shiva | grep a Its search in shiva folder character string for a (apple, bat, cat).
cat shiva | grep t$ It search for only last two letter ending with t (Eg:-Bat, ant, eat)
cat shiva | grep E p\{2} It search PP two same letter (Eg:- apple)
cat shiva | grep a\+t It will search for letter for at (Eg:- bat, eat, seat) in shiva folder.
sort shiva in shiva folder sort the file by name(A to Z).
sort r shiva Sort the files in the reverse order (Z to A).
env Displays all environment variables.
find ~ -empty Find all empty files in home directory.
grep -r "ramesh" * Search for a given string in all files recursively
vim +143 filename.txt Go to the 143rd line of file.
find -mtime +180 -exec rm -rf {} \; we can delete logs which are older than 180 days.
i Insert mode need to use up & Down arrow to move the cursor.
apachectl t check for syntax errors for apache.

ls s (R=Write, W=Write, X=Execute, - = No Permission)
chmod change mode Using this command we can set permissions (read, write, execute)file/Directory.
chown Change ownership of a file.
chgrp Command can change the group ownership with chgrp group filename.
Top Display all running process
kill pid Kill the process with given pid
killall proc Kill all the process named proc
cat /proc/cpuinfo Cpu information
cat proc/meminfo Memory information
ps -ef | more To view current running processes
service ssh status Check the status of a service.
service --status-all Check the status of all the services.
# cp file1 file2 Copy the contents of file1 to file2
cp -r dir1 dir2 Copy dir1 to dir2;create dir2 if not present
mv file1 file2 Rename or move file1 to file2,if file2 is an existing directory
find -mtime +180 -exec rm -rf {} \; we can delete logs which are older than 180 days
sort names.txt Sort a file in ascending order.
ls *.jpg | xargs -n1 -i cp {} /external-hard-drive/directory Copy all images to external hard-drive.
gzip test.txt To create a *.gz compressed file.
gzip -d test.txt.gz To uncompress a *.gz file.
gzip -l *.gz Display compression ratio of the compressed file using gzip l
compressed uncompressed ratio uncompressed name
23709 97975 75.8% asp-patch-rpms.txt
shutdown -h +10 Shutdown the system after 10 minutes.
Shutdown -r now Reboot the system using shutdown command.
Service --status-all Check the status of all the services.
ps -ef | more To view current running processes.
ps -efH | more To view current running processes in a tree structure. H stands for process hierarchy.
mkdir /u01 create a directory
mount /dev/sdb1 /u01 mount a file system.
pstree Processes and parent-child relationships.
top Show top processes
ps -auxw process status
cat /proc/version Display Linux kernel version in use.
service Red Hat/Fedora command to display status of system services. Example: service --status-all
du -sh Calculates file space usage for a given directory. (and everything under it) (-s option
summarizes)
mv bber.ear bber.ear.bk rename the file mv bber.ear to bber.ear.bk, so that we can place new file in
the same place.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
How to transfer the server logs from main server First need to login to server from where you want
to transfer eg:- ssh wbbh001cnc
cd /var/log/jboss
ll
scp server.log root@jaz01cnc:/home/web/
or mount path /mnt/applogs/BBHELP/wbbh001cnc
cd /var/log/jboss
cp server.log /mnt/applogs/BBHELP/wbbh001cnc

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Compression:- Tar Means Tape Archive.
1. c Creates a new .tar archive file.
2. v Verbosely show the .tar file progress.
3. f File name type of the archive file.
c create a archive file.
x extract a archive file.
v show the progress of archive file.
f filename of archive file.
t viewing content of archive file.
j filter archive through bzip2.
z filter archive through gzip.
r append or update files or directories to existing archive file.
W Verify an archive file.
tar cvf shift.tar orange green blue purple this command tag 4 shirts in one place or Bag.
tar xvf shift.tar Extract the all the files this command will use.
gzip car.txt Its will compress one time the car.txt file & display as car.txt.gz
bzip2 car.txt Its will compress two times the car.txt file & display as car.txt.gz2
gunzip car.txt.gz Its will extract or unzip one time the car.txt file & display as car.txt
bunzip2 car.txt .bz2 Its will extract or unzip two times the car.txt file & display as car.txt
tar cvzf shirts.tar.gz orange green blue purple it will compress shirts.tar one time.
tar cvjf shirts.tar.bz2 orange green blue purple it will compress shirts.tar two times.
tar xvzf shirts.tar.gz to extract the file shirts.tar one time
tar xvJf shirts.tar.bz2 to extract the file shirts.tar two times.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tar cf file.tar file Create tar named file.tar containing file
tar xf file.tar Extract the files from file.tar
tar czf file.tar.gz files Create a tar with Gzip compression
tar xzf file.tar.gz Extract a tar using Gzip
tar cjf file.tar.bz2 Create tar with Bzip2 compression
tar xjf file.tar.bz2 Extract a tar using Bzip2
gzip file Compresses file and renames it to file.gz
gzip -d file.gz Decompresses file.gz back to file
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
For /mnt/applogs/
we can delete logs which are older than 180 days, below is the command
ALWAYS BE IN /mnt/applogs/ directory and then run the following command.
cd /mnt/applogs/
find -mtime +180 -exec rm -rf {} \;
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Common Linux log files names and usage
/var/log/messages : General message and system related stuff
/var/log/auth.log : Authentication logs
/var/log/kern.log : Kernel logs
/var/log/cron.log : Crond logs (cron job)
/var/log/maillog : Mail server logs
/var/log/qmail/ : Qmail log directory (more files inside this directory)
/var/log/httpd/ : Apache access and error logs directory
/var/log/lighttpd/ : Lighttpd access and error logs directory
/var/log/boot.log : System boot log
/var/log/mysqld.log : MySQL database server log file
/var/log/secure or /var/log/auth.log : Authentication log
/var/log/utmp or /var/log/wtmp : Login records file
/var/log/yum.log : Yum command log file.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Absolute (Numeric) Mode:-
Number Permission Symbol
0 No Permission - - -
1 Execute - - x
2 Write -w-
3 Execute + Write -wx
4 Read r - -
5 Read + Execute r-x
6 Read + Write rw-
7 Read+Write+Execute rwx

Symbolic Mode:-
+ Adds a Permission to a file or directory
- Removes the Permission
= Sets the permission & Overrides the permissions set earlier

UserDenotations
U User/Owner
g Group
o Other
a All

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Proactive services restarts of Jboss & Apache
Log in to XYZ (WEOP001CNC) Server
apachectl stop
ps -ef | grep httpd [To make sure that apache is down]
service jboss stop
run: ps -ef | grep java [To make sure that jboss is down]
service jboss start [Once jboss is up, start apache]
apachectl start
Check apache and jboss logs
/var/log/httpd
/var/log/jboss
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
System Info
date Show the current date and time
cal Show this month's calendar
uptime Show current uptime
w Display who is online
whoami Who you are logged in as
finger user Display information about user
uname -a Show kernel information
cat /proc/cpuinfo CPU information
cat /proc/meminfo Memory information
df -h Show disk usage
du Show directory space usage
free Show memory and swap usage
Keyboard Shortcuts
Enter Run the command
Up Arrow Show the previous command
Ctrl + R Allows you to type a part of the command you're looking for and finds it
Ctrl + Z Stops the current command, resume with fg in the foreground or bg in the background
Ctrl + C Halts the current command, cancel the current operation and/or start with a fresh new line
Ctrl + L Clear the screen
command | less Allows the scrolling of the bash command window using Shift + Up Arrow and Shift +
Down Arrow
!! Repeats the last command
command !$ Repeats the last argument of the previous command
Esc + . (a period) Insert the last argument of the previous command on the fly, which enables you to
edit it before executing the command
Ctrl + A Return to the start of the command you're typing
Ctrl + E Go to the end of the command you're typing
Ctrl + U Cut everything before the cursor to a special clipboard, erases the whole line
Ctrl + K Cut everything after the cursor to a special clipboard
Ctrl + Y Paste from the special clipboard that Ctrl + U and Ctrl + K save their data to
Ctrl + T Swap the two characters before the cursor (you can actually use this to transport a character
from the left to the right, try it!)
Ctrl + W Delete the word / argument left of the cursor in the current line
Ctrl + D Log out of current session, similar to exit
Learn the Commands
apropos subject List manual pages for subject
man -k keyword Display man pages containing keyword
man command Show the manual for command
man -t man | ps2pdf - > man.pdf Make a pdf of a manual page
which command Show full path name of command
time command See how long a command takes
whereis app Show possible locations of app
which app Show which app will be run by default; it shows the full path
Searching
grep pattern files Search for pattern in files
grep -r pattern dir Search recursively for pattern in dir
command | grep pattern Search for pattern in the output of command
locate file Find all instances of file
find / -name filename Starting with the root directory, look for the file called filename
find / -name *filename* Starting with the root directory, look for the file containing the string
filename
locate filename Find a file called filename using the locate command; this assumes you have already
used the command updatedb (see next)
updatedb Create or update the database of files on all file systems attached to the Linux root directory
which filename Show the subdirectory containing the executable file called filename
grep TextStringToFind /dir Starting with the directory called dir, look for and list all files containing
TextString To Find
File Permissions
chmod octal file Change the permissions of file to octal, which can be found separately for user,
group, and world by adding: 4 read (r), 2 write (w), 1 execute (x)
Examples:
chmod 777 read, write, execute for all
chmod 755 rwx for owner, rx for group and world
For more options, see man chmod.
File Commands
ls Directory listing
ls -l List files in current directory using long format
ls -laC List all files in current directory in long format and display in columns
ls -F List files in current directory and indicate the file type
ls -al Formatted listing with hidden files
cd dir Change directory to dir
cd Change to home
mkdir dir Create a directory dir
pwd Show current directory
rm name Remove a file or directory called name
rm -r dir Delete directory dir
rm -f file Force remove file
rm -rf dir Force remove an entire directory dir and all its included files and subdirectories (use with
extreme caution)
cp file1 file2 Copy file1 to file2
cp -r dir1 dir2 Copy dir1 to dir2; create dir2 if it doesn't exist
cp file /home/dirname Copy the filename called file to the /home/dirname directory
mv file /home/dirname Move the file called filename to the /home/dirname directory
mv file1 file2 Rename or move file1 to file2; if file2 is an existing directory, moves file1 into directory
file2
ln -s file link Create symbolic link link to file
touch file Create or update file
cat > file Places standard input into file
cat file Display the file called file
more file Display the file called file one page at a time, proceed to next page using the spacebar
head file Output the first 10 lines of file
head -20 file Display the first 20 lines of the file called file
tail file Output the last 10 lines of file
tail -20 file Display the last 20 lines of the file called file
tail -f file Output the contents of file as it grows, starting with the last 10 lines
Compression
tar cf file.tar files Create a tar named file.tar containing files
tar xf file.tar Extract the files from file.tar
tar czf file.tar.gz files Create a tar with Gzip compression
tar xzf file.tar.gz Extract a tar using Gzip
tar cjf file.tar.bz2 Create a tar with Bzip2 compression
tar xjf file.tar.bz2 Extract a tar using Bzip2
gzip file Compresses file and renames it to file.gz
gzip -d file.gz Decompresses file.gz back to file
Printing
/etc/rc.d/init.d/lpd start Start the print daemon
/etc/rc.d/init.d/lpd stop Stop the print daemon
/etc/rc.d/init.d/lpd status Display status of the print daemon
lpq Display jobs in print queue
lprm Remove jobs from queue
lpr Print a file
lpc Printer control tool
man subject | lpr Print the manual page called subject as plain text
man -t subject | lpr Print the manual page called subject as Postscript output
printtool Start X printer setup interface
Network
ifconfig List IP addresses for all devices on the local machine
iwconfig Used to set the parameters of the network interface which are specific to the wireless
operation (for example: the frequency)
iwlist used to display some additional information from a wireless network interface that is not
displayed by iwconfig
ping host Ping host and output results
whois domain Get whois information for domain
dig domain Get DNS information for domain
dig -x host Reverse lookup host
wget file Download file
wget -c file Continue a stopped download
SSH
ssh user@host Connect to host as user
ssh -p port user@host Connect to host on port port as user
ssh-copy-id user@host Add your key to host for user to enable a keyed or passwordless login
User Administration
adduser accountname Create a new user call accountname
passwd accountname Give accountname a new password
su Log in as superuser from current login
exit Stop being superuser and revert to normal user
Process Management
ps Display your currently active processes
top Display all running processes
kill pid Kill process id pid
killall proc Kill all processes named proc (use with extreme caution)
bg Lists stopped or background jobs; resume a stopped job in the background
fg Brings the most recent job to foreground
fg n Brings job n to the foreground
Installation from source
./configure
make
make install
dpkg -i pkg.deb install a DEB package (Debian / Ubuntu / Linux Mint)
rpm -Uvh pkg.rpm install a RPM package (Red Hat / Fedora)
Stopping & Starting
shutdown -h now Shutdown the system now and do not reboot
halt Stop all processes - same as above
shutdown -r 5 Shutdown the system in 5 minutes and reboot
shutdown -r now Shutdown the system now and reboot
reboot Stop all processes and then reboot - same as above
startx Start the X system
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Potrebbero piacerti anche