Вы находитесь на странице: 1из 8

yes | cp -r /var/www/html/* /home/web/backup/ Its consider as Yes. No need to type Y ever time Y.

rm file Deleting the file

rm -r dir Deleting the directory

rm -f file Force to remove the file

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.

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)

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.

Apachectl graceful save the edited data in apache & restart 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.

chgrp Command can change the group ownership with chgrp group filename.
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

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.
============================================================================
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 {} \;
To create the 3 Folder in local path: Trevor Logs with name wmkt001cnc to 3cnc

[root@jaz01cnc Trevor_Logs]# mkdir wmkt001cnc wmkt002cnc wmkt003cnc

Coping from main server wmkt001cnc to jaz01cnc Trevor_Logs/ wmkt001cnc Server

[root@jaz01cnc wmkt001cnc ]# scp root@wmkt002cnc:/var/log/httpd/access_log-*.gz .

copy the Jboss Log that is server.log file from server wmkt001cnc from 14-07-0 to 9 date
scp root@wmkt001cnc:/var/log/jboss/server.log.2014-07-0? .

Linux IDE naming conventions:

Device Description Configuration


/dev/hda 1st (Primary) IDE controller Master
/dev/hdb 1st (Primary) IDE controller Slave
/dev/hdc 2nd (Secondary) IDE controller Master
/dev/hdd 2nd (Secondary) IDE controller Slave

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)

cd /var/log

cd httpd

ls -lrt

cd /var/log/jboss

ls -lrt

tail -100 access_log

tail -f access_log

Engage Unix Team

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/vg00-lv00
961M 356M 557M 39% /

/dev/mapper/vg00-lv01

4.8G 2.1G 2.5G 46% /usr

/dev/mapper/vg00-lv05

992M 34M 908M 4% /tmp

/dev/mapper/vg00-lv02

3.0G 2.1G 750M 74% /var

/dev/mapper/vg00-lv04

992M 424M 518M 46% /home

/dev/mapper/vg00-lv03

3.9G 983M 2.8G 27% /opt

/dev/sda1 487M 24M 438M 6% /boot

tmpfs 3.0G 0 3.0G 0% /dev/shm

Searching

grep pattern file Search for pattern in file

grep -r pattern dir Search recursively for pattern in dir

command | grep pattern Search pattern in the output of a command

locate file Find all instances of file

find . -name filename Searches in the current directory (represented by a period) and below it, for
files and directories with names starting with filename

pgrep pattern Searches for all the named processes , that matches with the pattern and, by default,
returns their ID

System Info

date Show the current date and time

cal Show this month's calender

uptime Show current uptime


w Display who is on line

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

man command Show the manual for command

df Show the disk usage

du Show directory space usage

free Show memory and swap usage

whereis app Show possible locations of app

which app Show which applications will be run by default

Вам также может понравиться