October20
In linux, we have a
command called which
This which command is used to tell the location of the executables
how to use ?
example :
kamaraj@kamaraj-laptop:~/Desktop/testing$ which ls
/bin/ls
kamaraj@kamaraj-laptop:~/Desktop/testing$ which ping
/bin/ping
kamaraj@kamaraj-laptop:~/Desktop/testing$ which cat
/bin/cat
October20
How to find the process id from the process name ?
In linux, you have a command called pidof
This pidof command is used to find out the process id of the given process name
Example:
kamaraj@kamaraj-laptop:~/Desktop/testing$ ps -ef | grep fire
kamaraj 6380 1 26 12:20 ? 00:30:32 /usr/lib/firefox-3.0.19/firefox
kamaraj 13107 12535 0 14:17 pts/0 00:00:00 grep fire
kamaraj@kamaraj-laptop:~/Desktop/testing$ pidof firefox
6380
October20
Top command is used to display linux tasks
when you do top command it will show the highly cpu consumable process in the top list.
if you want to capture and process the output of the top command then, you need to add some parameters to the top command.
-b –> batch mode operation
-n –> how many iterations
simply execute the command top -b -n1
The above command will give the output of the top command, Try it out and let me know if you have any doubts..
October20
Well, when you are exeuting any commands or scripts, the shell will internally do the system calls and do the job very quickly.
you want to trace the sytem calls and signals ?
lets try….
Example:
use strace command to trace the system calls
just do strace -c ls
you will get the list of system calls that made by the command ls
The best way to understand
do man strace
October20
You can use time to find out he execution time of any command or script
Example:
1
2
3
4
5
6
| $ time ls
01 - Veera.Mp3 02 - Usure Pogudhey.Mp3 03 - Kodu Poatta.Mp3 04 - Kaattu Sirukki.Mp3 05 - Kalvare.Mp3 06 - Keda Kari.Mp3
real 0m0.004s
user 0m0.000s
sys 0m0.004s |
$ time ls
01 - Veera.Mp3 02 - Usure Pogudhey.Mp3 03 - Kodu Poatta.Mp3 04 - Kaattu Sirukki.Mp3 05 - Kalvare.Mp3 06 - Keda Kari.Mp3
real 0m0.004s
user 0m0.000s
sys 0m0.004s
In the above example the time taken by the ls command is 0.004s
October20
1
2
| $ date -d "last monday"
Mon Jun 28 00:00:00 IST 2010 |
$ date -d "last monday"
Mon Jun 28 00:00:00 IST 2010
1
2
| $ date -d "last sunday"
Sun Jun 27 00:00:00 IST 2010 |
$ date -d "last sunday"
Sun Jun 27 00:00:00 IST 2010
1
2
| $ date -d "1 day ago"
Fri Jul 2 14:58:42 IST 2010 |
$ date -d "1 day ago"
Fri Jul 2 14:58:42 IST 2010
1
2
| $ date -d "2 days"
Mon Jul 5 14:59:02 IST 2010 |
$ date -d "2 days"
Mon Jul 5 14:59:02 IST 2010
1
2
| $ date -d "200 days"
Wed Jan 19 14:59:07 IST 2011 |
$ date -d "200 days"
Wed Jan 19 14:59:07 IST 2011
1
2
| $ date -d "last saturday" +%d-%m-%Y
26-06-2010 |
$ date -d "last saturday" +%d-%m-%Y
26-06-2010
1
2
| $ date -d "1 hour ago"
Sat Jul 3 14:01:09 IST 2010 |
$ date -d "1 hour ago"
Sat Jul 3 14:01:09 IST 2010
1
2
| $ date
Sat Jul 3 15:01:11 IST 2010 |
$ date
Sat Jul 3 15:01:11 IST 2010
October20
This is one of the trick in copy command
Normally we take backup the file using the following syntax
cp <file_name.sh> <file_name.sh.bak>
you can use do the samething like this also…
1
| cp file_name.{sh,sh.bak} |
cp file_name.{sh,sh.bak}
October20
Apropos is the command which search the entire manual (man) page entries and its description.
what is the usage of this command ?
we can easily get the Linux commands using the search word.
example :
The below output is for the search word “network”
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
| $ apropos network
/etc/network/interfaces (5) [interfaces] - network interface configuration for ifup and ifdown
aseqnet (1) - ALSA sequencer connectors over network
avahi-autoipd (8) - IPv4LL network address configuration daemon
bittorrent-downloader.bittorrent (1) - download files using a scatter-gather network
btdownloadcurses (1) - download files using a scatter-gather network
btdownloadcurses.bittorrent (1) - download files using a scatter-gather network
btdownloadgui (1) - download files using a scatter-gather network
btdownloadgui.bittorrent (1) - download files using a scatter-gather network
btdownloadheadless (1) - download files using a scatter-gather network
btdownloadheadless.bittorrent (1) - download files using a scatter-gather network
ctstat (8) - unified linux network statistics
dhclient-script (8) - DHCP client network configuration script
display-tele (7) - Forwards the display over a network
ifconfig (8) - configure a network interface
ifdown (8) - take a network interface down
ifup (8) - bring a network interface up
interfaces (5) - network interface configuration for ifup and ifdown
iwconfig (8) - configure a wireless network interface
iwgetid (8) - Report ESSID, NWID or AP/Cell Address of wireless network
iwpriv (8) - configure optionals (private) parameters of a wireless network interface
jng (5) - JPEG Network Graphics (JNG) sub-format
libmng (3) - Multiple-image Network Graphics (MNG) Reference Library 1.0.9
libpng (3) - Portable Network Graphics (PNG) Reference Library 1.2.27
lnstat (8) - unified linux network statistics
mng (5) - Multiple-image Network Graphics (MNG) format
mtr (8) - a network diagnostic tool
nameif (8) - name network interfaces based on MAC addresses
Net::Cmd (3perl) - Network Command class (as used by FTP, SMTP etc)
Net::Time (3perl) - time and daytime network client interface
netdevice (7) - Low level access to Linux network devices
netstat (8) - Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships
network-admin (1) - Network Administration Tool
NetworkManager (8) - network management daemon
networks (5) - network name information
nm-tool (1) - utility to report NetworkManager state
nm-vpn-properties (1) - Network management framework
nmap (1) - Network exploration tool and security / port scanner
nstat (8) - network statistics tools.
pabrowse (1) - List PulseAudio sound servers on the network
perlfaq9 (1) - Networking ($Revision: 8539 $)
ping (8) - send ICMP ECHO_REQUEST to network hosts
ping6 (8) - send ICMP ECHO_REQUEST to network hosts
png (5) - Portable Network Graphics (PNG) format
rtacct (8) - network statistics tools.
rtstat (8) - unified linux network statistics
sane-net (5) - SANE network backend
saned (8) - SANE network daemon
services (5) - Internet network services list
slattach (8) - attach a network interface to a serial line
smbtree (1) - A text based smb network browser
tcpdump (8) - dump traffic on a network
tracepath (8) - traces path to a network host discovering MTU along this path
tracepath6 (8) - traces path to a network host discovering MTU along this path
traceroute6 (8) - traces path to a network host
traceroute6.iputils (8) - traces path to a network host
wget (1) - The non-interactive network downloader. |
$ apropos network
/etc/network/interfaces (5) [interfaces] - network interface configuration for ifup and ifdown
aseqnet (1) - ALSA sequencer connectors over network
avahi-autoipd (8) - IPv4LL network address configuration daemon
bittorrent-downloader.bittorrent (1) - download files using a scatter-gather network
btdownloadcurses (1) - download files using a scatter-gather network
btdownloadcurses.bittorrent (1) - download files using a scatter-gather network
btdownloadgui (1) - download files using a scatter-gather network
btdownloadgui.bittorrent (1) - download files using a scatter-gather network
btdownloadheadless (1) - download files using a scatter-gather network
btdownloadheadless.bittorrent (1) - download files using a scatter-gather network
ctstat (8) - unified linux network statistics
dhclient-script (8) - DHCP client network configuration script
display-tele (7) - Forwards the display over a network
ifconfig (8) - configure a network interface
ifdown (8) - take a network interface down
ifup (8) - bring a network interface up
interfaces (5) - network interface configuration for ifup and ifdown
iwconfig (8) - configure a wireless network interface
iwgetid (8) - Report ESSID, NWID or AP/Cell Address of wireless network
iwpriv (8) - configure optionals (private) parameters of a wireless network interface
jng (5) - JPEG Network Graphics (JNG) sub-format
libmng (3) - Multiple-image Network Graphics (MNG) Reference Library 1.0.9
libpng (3) - Portable Network Graphics (PNG) Reference Library 1.2.27
lnstat (8) - unified linux network statistics
mng (5) - Multiple-image Network Graphics (MNG) format
mtr (8) - a network diagnostic tool
nameif (8) - name network interfaces based on MAC addresses
Net::Cmd (3perl) - Network Command class (as used by FTP, SMTP etc)
Net::Time (3perl) - time and daytime network client interface
netdevice (7) - Low level access to Linux network devices
netstat (8) - Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships
network-admin (1) - Network Administration Tool
NetworkManager (8) - network management daemon
networks (5) - network name information
nm-tool (1) - utility to report NetworkManager state
nm-vpn-properties (1) - Network management framework
nmap (1) - Network exploration tool and security / port scanner
nstat (8) - network statistics tools.
pabrowse (1) - List PulseAudio sound servers on the network
perlfaq9 (1) - Networking ($Revision: 8539 $)
ping (8) - send ICMP ECHO_REQUEST to network hosts
ping6 (8) - send ICMP ECHO_REQUEST to network hosts
png (5) - Portable Network Graphics (PNG) format
rtacct (8) - network statistics tools.
rtstat (8) - unified linux network statistics
sane-net (5) - SANE network backend
saned (8) - SANE network daemon
services (5) - Internet network services list
slattach (8) - attach a network interface to a serial line
smbtree (1) - A text based smb network browser
tcpdump (8) - dump traffic on a network
tracepath (8) - traces path to a network host discovering MTU along this path
tracepath6 (8) - traces path to a network host discovering MTU along this path
traceroute6 (8) - traces path to a network host
traceroute6.iputils (8) - traces path to a network host
wget (1) - The non-interactive network downloader.
Recent Comments