SlideShare ist ein Scribd-Unternehmen logo
1 von 26
Downloaden Sie, um offline zu lesen
Linux Commands & Tools
v1.3
j3ffyang at gmail
Environment Setting
BaSH, Bourne Again SHell (Linux default), vs. Korn Shell (on
AIX)
Current env
env
System wide/ global
/etc/bashrc -> aliases and functions (read always, login-
shell and non-login-shell)
/etc/profile -> env (read when login- shell)
User base
~/.bashrc (/etc/bashrc read first, then ~/.bashrc)
~/.profile
/etc/skel -> system level files copied to /home/user when
created
Environment Setting
Objective:
Run WAS_installdir/bin/setupCmdLine.sh correctly
Solution:
#!/bin/sh (symlinked to /bin/bash)
source /file (run in current shell)
. file.sh (same as above)
./file.sh (run in child shell process)
pstree
Hardware Specification
Objective:
How fast is CPU? How big is RAM? SWAP size?
Solution:
cat /proc/cpuinfo
cat /proc/meminfo
cat /proc/swaps
System Specification
Objective:
How to partition harddisk before installing WebSphere
Commerce?
Solution:
/boot 100MB
/ 10G
SWAP =<2 x RAM (usually 1~ 1.2G if RAM=1G)
http://www.redhat.com/docs/manuals/enterprise/RHEL­4­Manual/pdf/rhel­ig­x8664­multi­en.pdf
­> page 28
Kernel - Messaging
Objective:
Optimize kernel for DB2.
Solution:
Display kernel parameter
ipcs ­l
Display kernel parameter
Editing /etc/sysctl.conf
kernel.msgmni = 512
kernel.sem=250  128000  32 1024
Activating kernel parameters
sysctl ­p
http://www­106.ibm.com/developerworks/linux/library/l­ss3­db2/
System Management
Objective:
Want to how the file system being used?
Solution:
du -cks $(ls -l | grep '^d' | awk '{print $9}') | sort -nr
du -ksh
System Startup
Objective:
Switch between X startup and command line startup.
Change the runlevel.
Solution:
cat /etc/inittab | grep “id”
System Mgmt - fuser
Objective:
Which process holds up the file?
Solution:
fuser
pid
[root@sevenj root]# fuser /var/log/messages
/var/log/messages: 3292
User
[root@sevenj root]# fuser -u /var/log/messages
/var/log/messages: 3292(root)
Terminate the processes that using file
fuser -kimuv /path/file
fuser -kxuc /path/file (on AIX)
Port
[root@sevenj root]# fuser 22/tcp
22/tcp: 3470
System Mgmt - lsof
Objective:
Which program is running over a port?
Solution:
lsof – LiSt Open File
Which application is using port 22?
lsof -i:22
[root@summerpalace /]# lsof -i:22
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
sshd 3803 root 3u IPv4 3387 TCP *:ssh(LISTEN)
sshd 30328 root 4u IPv4 2616339 TCP
summerpalace.torolab.ibm.com:ssh->9.26.190.11:33875 (ESTABLISHED)
System Mgmt – lsof (cont'd)
What files are opened by PID?
[root@summerpalace /]# lsof -p 3803
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
sshd 3803 root cwd DIR 3,2 4096 2 /
sshd 3803 root rtd DIR 3,2 4096 2 /
sshd 3803 root txt REG 3,2 280184 551800 /usr/sbin/sshd
sshd 3803 root mem REG 3,2 51924 535486 /lib/libnss_files-2.3.2.so
sshd 3803 root mem REG 3,2 1563240 1054615 /lib/tls/libc-2.3.2.so
sshd 3803 root mem REG 3,2 5572 292096 /usr/kerberos/lib/libcom_err.so.3.0
sshd 3803 root mem REG 3,2 63880 292106 /usr/kerberos/lib/libk5crypto.so.3.0
sshd 3803 root mem REG 3,2 385220 292116 /usr/kerberos/lib/libkrb5.so.3.1
sshd 3803 root mem REG 3,2 971612 535528 /lib/libcrypto.so.0.9.7a
sshd 3803 root mem REG 3,2 91368 535470 /lib/libnsl-2.3.2.so
sshd 3803 root mem REG 3,2 52584 1216870 /usr/lib/libz.so.1.1.4
sshd 3803 root mem REG 3,2 12564 535504 /lib/libutil-2.3.2.so
sshd 3803 root mem REG 3,2 76468 535498 /lib/libresolv-2.3.2.so
sshd 3803 root mem REG 3,2 14728 535466 /lib/libdl-2.3.2.so
sshd 3803 root mem REG 3,2 30448 535533 /lib/libpam.so.0.75
sshd 3803 root mem REG 3,2 28452 1216947 /usr/lib/libwrap.so.0.7.6
sshd 3803 root mem REG 3,2 106532 535453 /lib/ld-2.3.2.so
sshd 3803 root 0u CHR 1,3 66540 /dev/null
sshd 3803 root 1u CHR 1,3 66540 /dev/null
sshd 3803 root 2u CHR 1,3 66540 /dev/null
sshd 3803 root 3u IPv4 3387 TCP *:ssh (LISTEN)
System Mgmt – lsof (cont'd)
What application is holding a dir and files under that dir?
[root@summerpalace /]# lsof +d /var/log
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
syslogd 3676 root 2w REG 3,2 1393576 780963 /var/log/messages
syslogd 3676 root 3w REG 3,2 925 780964 /var/log/secure
syslogd 3676 root 4w REG 3,2 430 781130 /var/log/maillog
syslogd 3676 root 5w REG 3,2 10246 781139 /var/log/cron
syslogd 3676 root 6w REG 3,2 0 781134 /var/log/spooler
syslogd 3676 root 7w REG 3,2 0 781138 /var/log/boot.log
System Mgmt – SWAP
Objective:
Want to change SWAP size?
Solution:
mkswap /dev/hdaX
sync
swapon /dev/hdaX
cat /proc/swaps
System Mgmt – mkfs
Objective:
Create a file system?
Solution:
fdisk -l
fdisk /dev/hda
mkfs -t ext3 /dev/hdaX
mkfs /dev/hdaX
tune2fs -j /dev/hdaX (Convert ext2 to ext3. Journaled.)
mount /dev/hdaX /mount/point
Edit /etc/fstab
/dev/hdaX /mount/point ext3 defaults 1 2
File - compression
Objective:
Compress/ Uncompress? The archive formats?
Solution:
Compress
zip *.zip
jar *.jar (same as zip)
tar -czvf *.tar.gz
bzip2 *.bz2
gzip *.gz / *.Z
rar (http://www.rarlab.com/)
Uncompress
unzip
jar -xvf
tar -xzvf
bunzip2
gunzip
File - editor
Objective:
Edit the file?
Solution:
vi
kate (Similar to UltraEdit. Install kdebase*.rpm)
jedit (http://jedit.org)
emacs
ed
Network
Objective: Get the DHCP IP+ Register hostname in DNS
Solution:
/etc/sysconfig/network
dhclient ethX /dhclient.conf (man dhclient.conf -> sample)
YaST or YaST2 (Yet another Setup Tools)
/etc/hosts
Edit /etc/sysconfig/network-scripts/ifcfg-ethX
Add DHCP_HOSTNAME=<your_hostname>
Verification:
hostname -s / -d
nslookup / host / dig
Network - netstat
Objective:
Network status.
Solution:
TCP/IP
netstat -pant
netstat -pat
Network – http/ftp
Objective:
Run ftp client in command line?
Solution:
wget -t3 -c -r -l 10 http://domain.org
-t= retry, -c= continue, -r= recursive,
-l= depth (level of subdirectories)
Performance - Process
Objective:
The running processes' status?
Solution:
How much the CPU usage?
ps auxwww | sort +2 -r
ps -ef | sort +3 -r | head -n 5
How much the MEM usage?
ps auxwww | sort +3 -r
The process tree.
pstree
Performance – Manage Srvc
Objective:
Turn on / off the unnecessary services.
Solution:
List all available services.
chkconfig --list
chkconfig –-list | grep 3:on
Check on / out services. eg.
chkconfig iptables on | off
chkconfig –level 2345 iptables on
less /etc/init.d/iptables
ls /etc/rc.d/rc3.d
Stop a service. eg.
/etc/init.d/sshd start | stop
Performance - Memory
Objective: System memory usuage.
Solution:
vmstat <interval> <length>
eg.
vmstat 1 10
[root@summerpalace root]# vmstat 1 10
procs memory swap io system cpu
r b swpd free buff cache si so bi bo in cs us sy id wa
1 0 0 146512 107140 616064 0 0 4 17 105 30 0 0 99 0
0 0 0 146428 107140 616064 0 0 0 148 130 76 0 4 96 0
r: The number of processes waiting for run time.
si / so: Swap in/ out
bi / bo: Blocks in/ out
us: User time
sy: System time
id: Idle
Reference: What's block and character device?
http://www.uwsg.iu.edu/usail/concepts/filesystems/everything­is­a­file.html
Performance - top
Objective:
Overall system performance.
Solution:
top
s – interval in second
M – sort by memory
P – sort by CPU
RPM
Objective: Manage the packages
Solutions:
RPM = RedHat Package Manager. Used by RedHat, SuSE and Mandrake.
Debian dpkg converter is available.
Install / Update
rpm -Uvh package.rpm (vs. -ivh)
rpm -Uvh package.rpm --nodeps
rpm -Uvh –-aid package.rpm (require rpmdb-*.rpm installed)
Uninstall
rpm -e package_name
rpm -e –-allmatches package (man rpm, search allmatches)
RPM DB Rebuild
db_verify /var/lib/rpm/Packages
rpmdb --rebuilddb
RPM (cont'd)
Solutions:
Find an RPM
rpm -qa | grep -i package_name
Which rpm does a file belong to?
rpm -qf /path/file
The pre- requisite of an RPM?
rpm -q –-requires mozilla
Where is the RPM installed?
rpm -qil mozilla
Check RPM's changelog
rpm -qi mozilla
MultiMedia :-)
Objective: Have fun in work with Linux :-)
Solution:
xmms (Play MP3)
grip (Rip wave to MP3)
Make ISO file for burning disc
mkisofs -r -o file.iso /path/files
Test to mount
mount -t iso9660 -o ro,loop=/dev/loop0 file.iso /mnt/tmp
Scan CD writer
cdrecrd -scanbus
Write ISO to disc
cdrecord -v speed=8 dev=0,0,0 -data file.iso
GUI CD write -> http://www.xcdroast.org/
xcdroast

Weitere ähnliche Inhalte

Was ist angesagt?

101 2.2 install boot manager
101 2.2 install boot manager101 2.2 install boot manager
101 2.2 install boot manager
Acácio Oliveira
 
FreeBSD Jail Complete Example
FreeBSD Jail Complete ExampleFreeBSD Jail Complete Example
FreeBSD Jail Complete Example
Mohammed Farrag
 
Module 13 - Troubleshooting
Module 13 - TroubleshootingModule 13 - Troubleshooting
Module 13 - Troubleshooting
T. J. Saotome
 

Was ist angesagt? (20)

Log
LogLog
Log
 
High Availability Server with DRBD in linux
High Availability Server with DRBD in linuxHigh Availability Server with DRBD in linux
High Availability Server with DRBD in linux
 
Linux fundamental - Chap 04 archive
Linux fundamental - Chap 04 archiveLinux fundamental - Chap 04 archive
Linux fundamental - Chap 04 archive
 
Linux fundamental - Chap 11 boot
Linux fundamental - Chap 11 bootLinux fundamental - Chap 11 boot
Linux fundamental - Chap 11 boot
 
101 2.2 install boot manager
101 2.2 install boot manager101 2.2 install boot manager
101 2.2 install boot manager
 
unixtoolbox
unixtoolboxunixtoolbox
unixtoolbox
 
Solaris_quickref.pdf
Solaris_quickref.pdfSolaris_quickref.pdf
Solaris_quickref.pdf
 
Linux fundamental - Chap 12 Hardware Management
Linux fundamental - Chap 12 Hardware ManagementLinux fundamental - Chap 12 Hardware Management
Linux fundamental - Chap 12 Hardware Management
 
Linux Troubleshooting
Linux TroubleshootingLinux Troubleshooting
Linux Troubleshooting
 
Lecture1 Introduction
Lecture1  IntroductionLecture1  Introduction
Lecture1 Introduction
 
KCC_Final.pdf
KCC_Final.pdfKCC_Final.pdf
KCC_Final.pdf
 
FreeBSD Jail Complete Example
FreeBSD Jail Complete ExampleFreeBSD Jail Complete Example
FreeBSD Jail Complete Example
 
Lecture 4 FreeBSD Security + FreeBSD Jails + MAC Security Framework
Lecture 4 FreeBSD Security + FreeBSD Jails + MAC Security FrameworkLecture 4 FreeBSD Security + FreeBSD Jails + MAC Security Framework
Lecture 4 FreeBSD Security + FreeBSD Jails + MAC Security Framework
 
A Journey to Boot Linux on Raspberry Pi
A Journey to Boot Linux on Raspberry PiA Journey to Boot Linux on Raspberry Pi
A Journey to Boot Linux on Raspberry Pi
 
SiteGround Tech TeamBuilding
SiteGround Tech TeamBuildingSiteGround Tech TeamBuilding
SiteGround Tech TeamBuilding
 
101 1.1 hardware settings
101 1.1 hardware settings101 1.1 hardware settings
101 1.1 hardware settings
 
Free Bsd7.2 Install V1.7
Free Bsd7.2 Install V1.7Free Bsd7.2 Install V1.7
Free Bsd7.2 Install V1.7
 
[ArabBSD] Unix Basics
[ArabBSD] Unix Basics[ArabBSD] Unix Basics
[ArabBSD] Unix Basics
 
101 2.1 design hard disk layout v2
101 2.1 design hard disk layout v2101 2.1 design hard disk layout v2
101 2.1 design hard disk layout v2
 
Module 13 - Troubleshooting
Module 13 - TroubleshootingModule 13 - Troubleshooting
Module 13 - Troubleshooting
 

Ähnlich wie Linux Common Command

101 2.1 design hard disk layout
101 2.1 design hard disk layout101 2.1 design hard disk layout
101 2.1 design hard disk layout
Acácio Oliveira
 
SANS @Night There's Gold in Them Thar Package Management Databases
SANS @Night There's Gold in Them Thar Package Management DatabasesSANS @Night There's Gold in Them Thar Package Management Databases
SANS @Night There's Gold in Them Thar Package Management Databases
Phil Hagen
 

Ähnlich wie Linux Common Command (20)

Linux filesystemhierarchy
Linux filesystemhierarchyLinux filesystemhierarchy
Linux filesystemhierarchy
 
Advanced Level Training on Koha / TLS (ToT)
Advanced Level Training on Koha / TLS (ToT)Advanced Level Training on Koha / TLS (ToT)
Advanced Level Training on Koha / TLS (ToT)
 
Linux Capabilities - eng - v2.1.5, compact
Linux Capabilities - eng - v2.1.5, compactLinux Capabilities - eng - v2.1.5, compact
Linux Capabilities - eng - v2.1.5, compact
 
Devops for beginners
Devops for beginnersDevops for beginners
Devops for beginners
 
101 2.1 design hard disk layout
101 2.1 design hard disk layout101 2.1 design hard disk layout
101 2.1 design hard disk layout
 
Analyze corefile and backtraces with GDB for Mysql/MariaDB on Linux - Nilanda...
Analyze corefile and backtraces with GDB for Mysql/MariaDB on Linux - Nilanda...Analyze corefile and backtraces with GDB for Mysql/MariaDB on Linux - Nilanda...
Analyze corefile and backtraces with GDB for Mysql/MariaDB on Linux - Nilanda...
 
Linux Survival Kit for Proof of Concept & Proof of Technology
Linux Survival Kit for Proof of Concept & Proof of TechnologyLinux Survival Kit for Proof of Concept & Proof of Technology
Linux Survival Kit for Proof of Concept & Proof of Technology
 
Designing Tracing Tools
Designing Tracing ToolsDesigning Tracing Tools
Designing Tracing Tools
 
2.1 design hard disk layout v2
2.1 design hard disk layout v22.1 design hard disk layout v2
2.1 design hard disk layout v2
 
configuring a warm standby, the easy way
configuring a warm standby, the easy wayconfiguring a warm standby, the easy way
configuring a warm standby, the easy way
 
Tutorial 2
Tutorial 2Tutorial 2
Tutorial 2
 
Rh202 q&amp;a-demo-cert magic
Rh202 q&amp;a-demo-cert magicRh202 q&amp;a-demo-cert magic
Rh202 q&amp;a-demo-cert magic
 
Working with core dump
Working with core dumpWorking with core dump
Working with core dump
 
An Introduction To Linux
An Introduction To LinuxAn Introduction To Linux
An Introduction To Linux
 
Death matchtournament del2014
Death matchtournament del2014Death matchtournament del2014
Death matchtournament del2014
 
SANS @Night There's Gold in Them Thar Package Management Databases
SANS @Night There's Gold in Them Thar Package Management DatabasesSANS @Night There's Gold in Them Thar Package Management Databases
SANS @Night There's Gold in Them Thar Package Management Databases
 
Pitr Made Easy
Pitr Made EasyPitr Made Easy
Pitr Made Easy
 
Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internals
 
RH-302 Exam-Red Hat Certified Engineer on Redhat Enterprise Linux 4 (Labs)
RH-302 Exam-Red Hat Certified Engineer on Redhat Enterprise Linux 4 (Labs)RH-302 Exam-Red Hat Certified Engineer on Redhat Enterprise Linux 4 (Labs)
RH-302 Exam-Red Hat Certified Engineer on Redhat Enterprise Linux 4 (Labs)
 
Andresen 8 21 02
Andresen 8 21 02Andresen 8 21 02
Andresen 8 21 02
 

Mehr von Jeff Yang (11)

BlockChain and Its Eco-System
BlockChain and Its Eco-SystemBlockChain and Its Eco-System
BlockChain and Its Eco-System
 
20140513_jeffyang_demo_openstack
20140513_jeffyang_demo_openstack20140513_jeffyang_demo_openstack
20140513_jeffyang_demo_openstack
 
20131015_demo_oshk
20131015_demo_oshk20131015_demo_oshk
20131015_demo_oshk
 
An High Available Database for OpenStack Cloud Production by Pacemaker, Coros...
An High Available Database for OpenStack Cloud Production by Pacemaker, Coros...An High Available Database for OpenStack Cloud Production by Pacemaker, Coros...
An High Available Database for OpenStack Cloud Production by Pacemaker, Coros...
 
Ubuntu Tweak for Fun
Ubuntu Tweak for FunUbuntu Tweak for Fun
Ubuntu Tweak for Fun
 
Art of Coding/ Innovation
Art of Coding/ InnovationArt of Coding/ Innovation
Art of Coding/ Innovation
 
The combination of Cloud Computing, Web2.0 and Innovation
The combination of Cloud Computing, Web2.0 and InnovationThe combination of Cloud Computing, Web2.0 and Innovation
The combination of Cloud Computing, Web2.0 and Innovation
 
Cloud Computing Technology Trend Watch
Cloud Computing Technology Trend WatchCloud Computing Technology Trend Watch
Cloud Computing Technology Trend Watch
 
Innovation around Twitter
Innovation around TwitterInnovation around Twitter
Innovation around Twitter
 
Twitter
TwitterTwitter
Twitter
 
IBM Development and Test Cloud
IBM Development and Test CloudIBM Development and Test Cloud
IBM Development and Test Cloud
 

Kürzlich hochgeladen

%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Kürzlich hochgeladen (20)

%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 

Linux Common Command

  • 1. Linux Commands & Tools v1.3 j3ffyang at gmail
  • 2. Environment Setting BaSH, Bourne Again SHell (Linux default), vs. Korn Shell (on AIX) Current env env System wide/ global /etc/bashrc -> aliases and functions (read always, login- shell and non-login-shell) /etc/profile -> env (read when login- shell) User base ~/.bashrc (/etc/bashrc read first, then ~/.bashrc) ~/.profile /etc/skel -> system level files copied to /home/user when created
  • 3. Environment Setting Objective: Run WAS_installdir/bin/setupCmdLine.sh correctly Solution: #!/bin/sh (symlinked to /bin/bash) source /file (run in current shell) . file.sh (same as above) ./file.sh (run in child shell process) pstree
  • 4. Hardware Specification Objective: How fast is CPU? How big is RAM? SWAP size? Solution: cat /proc/cpuinfo cat /proc/meminfo cat /proc/swaps
  • 5. System Specification Objective: How to partition harddisk before installing WebSphere Commerce? Solution: /boot 100MB / 10G SWAP =<2 x RAM (usually 1~ 1.2G if RAM=1G) http://www.redhat.com/docs/manuals/enterprise/RHEL­4­Manual/pdf/rhel­ig­x8664­multi­en.pdf ­> page 28
  • 6. Kernel - Messaging Objective: Optimize kernel for DB2. Solution: Display kernel parameter ipcs ­l Display kernel parameter Editing /etc/sysctl.conf kernel.msgmni = 512 kernel.sem=250  128000  32 1024 Activating kernel parameters sysctl ­p http://www­106.ibm.com/developerworks/linux/library/l­ss3­db2/
  • 7. System Management Objective: Want to how the file system being used? Solution: du -cks $(ls -l | grep '^d' | awk '{print $9}') | sort -nr du -ksh
  • 8. System Startup Objective: Switch between X startup and command line startup. Change the runlevel. Solution: cat /etc/inittab | grep “id”
  • 9. System Mgmt - fuser Objective: Which process holds up the file? Solution: fuser pid [root@sevenj root]# fuser /var/log/messages /var/log/messages: 3292 User [root@sevenj root]# fuser -u /var/log/messages /var/log/messages: 3292(root) Terminate the processes that using file fuser -kimuv /path/file fuser -kxuc /path/file (on AIX) Port [root@sevenj root]# fuser 22/tcp 22/tcp: 3470
  • 10. System Mgmt - lsof Objective: Which program is running over a port? Solution: lsof – LiSt Open File Which application is using port 22? lsof -i:22 [root@summerpalace /]# lsof -i:22 COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME sshd 3803 root 3u IPv4 3387 TCP *:ssh(LISTEN) sshd 30328 root 4u IPv4 2616339 TCP summerpalace.torolab.ibm.com:ssh->9.26.190.11:33875 (ESTABLISHED)
  • 11. System Mgmt – lsof (cont'd) What files are opened by PID? [root@summerpalace /]# lsof -p 3803 COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME sshd 3803 root cwd DIR 3,2 4096 2 / sshd 3803 root rtd DIR 3,2 4096 2 / sshd 3803 root txt REG 3,2 280184 551800 /usr/sbin/sshd sshd 3803 root mem REG 3,2 51924 535486 /lib/libnss_files-2.3.2.so sshd 3803 root mem REG 3,2 1563240 1054615 /lib/tls/libc-2.3.2.so sshd 3803 root mem REG 3,2 5572 292096 /usr/kerberos/lib/libcom_err.so.3.0 sshd 3803 root mem REG 3,2 63880 292106 /usr/kerberos/lib/libk5crypto.so.3.0 sshd 3803 root mem REG 3,2 385220 292116 /usr/kerberos/lib/libkrb5.so.3.1 sshd 3803 root mem REG 3,2 971612 535528 /lib/libcrypto.so.0.9.7a sshd 3803 root mem REG 3,2 91368 535470 /lib/libnsl-2.3.2.so sshd 3803 root mem REG 3,2 52584 1216870 /usr/lib/libz.so.1.1.4 sshd 3803 root mem REG 3,2 12564 535504 /lib/libutil-2.3.2.so sshd 3803 root mem REG 3,2 76468 535498 /lib/libresolv-2.3.2.so sshd 3803 root mem REG 3,2 14728 535466 /lib/libdl-2.3.2.so sshd 3803 root mem REG 3,2 30448 535533 /lib/libpam.so.0.75 sshd 3803 root mem REG 3,2 28452 1216947 /usr/lib/libwrap.so.0.7.6 sshd 3803 root mem REG 3,2 106532 535453 /lib/ld-2.3.2.so sshd 3803 root 0u CHR 1,3 66540 /dev/null sshd 3803 root 1u CHR 1,3 66540 /dev/null sshd 3803 root 2u CHR 1,3 66540 /dev/null sshd 3803 root 3u IPv4 3387 TCP *:ssh (LISTEN)
  • 12. System Mgmt – lsof (cont'd) What application is holding a dir and files under that dir? [root@summerpalace /]# lsof +d /var/log COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME syslogd 3676 root 2w REG 3,2 1393576 780963 /var/log/messages syslogd 3676 root 3w REG 3,2 925 780964 /var/log/secure syslogd 3676 root 4w REG 3,2 430 781130 /var/log/maillog syslogd 3676 root 5w REG 3,2 10246 781139 /var/log/cron syslogd 3676 root 6w REG 3,2 0 781134 /var/log/spooler syslogd 3676 root 7w REG 3,2 0 781138 /var/log/boot.log
  • 13. System Mgmt – SWAP Objective: Want to change SWAP size? Solution: mkswap /dev/hdaX sync swapon /dev/hdaX cat /proc/swaps
  • 14. System Mgmt – mkfs Objective: Create a file system? Solution: fdisk -l fdisk /dev/hda mkfs -t ext3 /dev/hdaX mkfs /dev/hdaX tune2fs -j /dev/hdaX (Convert ext2 to ext3. Journaled.) mount /dev/hdaX /mount/point Edit /etc/fstab /dev/hdaX /mount/point ext3 defaults 1 2
  • 15. File - compression Objective: Compress/ Uncompress? The archive formats? Solution: Compress zip *.zip jar *.jar (same as zip) tar -czvf *.tar.gz bzip2 *.bz2 gzip *.gz / *.Z rar (http://www.rarlab.com/) Uncompress unzip jar -xvf tar -xzvf bunzip2 gunzip
  • 16. File - editor Objective: Edit the file? Solution: vi kate (Similar to UltraEdit. Install kdebase*.rpm) jedit (http://jedit.org) emacs ed
  • 17. Network Objective: Get the DHCP IP+ Register hostname in DNS Solution: /etc/sysconfig/network dhclient ethX /dhclient.conf (man dhclient.conf -> sample) YaST or YaST2 (Yet another Setup Tools) /etc/hosts Edit /etc/sysconfig/network-scripts/ifcfg-ethX Add DHCP_HOSTNAME=<your_hostname> Verification: hostname -s / -d nslookup / host / dig
  • 18. Network - netstat Objective: Network status. Solution: TCP/IP netstat -pant netstat -pat
  • 19. Network – http/ftp Objective: Run ftp client in command line? Solution: wget -t3 -c -r -l 10 http://domain.org -t= retry, -c= continue, -r= recursive, -l= depth (level of subdirectories)
  • 20. Performance - Process Objective: The running processes' status? Solution: How much the CPU usage? ps auxwww | sort +2 -r ps -ef | sort +3 -r | head -n 5 How much the MEM usage? ps auxwww | sort +3 -r The process tree. pstree
  • 21. Performance – Manage Srvc Objective: Turn on / off the unnecessary services. Solution: List all available services. chkconfig --list chkconfig –-list | grep 3:on Check on / out services. eg. chkconfig iptables on | off chkconfig –level 2345 iptables on less /etc/init.d/iptables ls /etc/rc.d/rc3.d Stop a service. eg. /etc/init.d/sshd start | stop
  • 22. Performance - Memory Objective: System memory usuage. Solution: vmstat <interval> <length> eg. vmstat 1 10 [root@summerpalace root]# vmstat 1 10 procs memory swap io system cpu r b swpd free buff cache si so bi bo in cs us sy id wa 1 0 0 146512 107140 616064 0 0 4 17 105 30 0 0 99 0 0 0 0 146428 107140 616064 0 0 0 148 130 76 0 4 96 0 r: The number of processes waiting for run time. si / so: Swap in/ out bi / bo: Blocks in/ out us: User time sy: System time id: Idle Reference: What's block and character device? http://www.uwsg.iu.edu/usail/concepts/filesystems/everything­is­a­file.html
  • 23. Performance - top Objective: Overall system performance. Solution: top s – interval in second M – sort by memory P – sort by CPU
  • 24. RPM Objective: Manage the packages Solutions: RPM = RedHat Package Manager. Used by RedHat, SuSE and Mandrake. Debian dpkg converter is available. Install / Update rpm -Uvh package.rpm (vs. -ivh) rpm -Uvh package.rpm --nodeps rpm -Uvh –-aid package.rpm (require rpmdb-*.rpm installed) Uninstall rpm -e package_name rpm -e –-allmatches package (man rpm, search allmatches) RPM DB Rebuild db_verify /var/lib/rpm/Packages rpmdb --rebuilddb
  • 25. RPM (cont'd) Solutions: Find an RPM rpm -qa | grep -i package_name Which rpm does a file belong to? rpm -qf /path/file The pre- requisite of an RPM? rpm -q –-requires mozilla Where is the RPM installed? rpm -qil mozilla Check RPM's changelog rpm -qi mozilla
  • 26. MultiMedia :-) Objective: Have fun in work with Linux :-) Solution: xmms (Play MP3) grip (Rip wave to MP3) Make ISO file for burning disc mkisofs -r -o file.iso /path/files Test to mount mount -t iso9660 -o ro,loop=/dev/loop0 file.iso /mnt/tmp Scan CD writer cdrecrd -scanbus Write ISO to disc cdrecord -v speed=8 dev=0,0,0 -data file.iso GUI CD write -> http://www.xcdroast.org/ xcdroast