Quantcast
Channel: Greetz to Geeks
Viewing all articles
Browse latest Browse all 10

Interesting commands in Ubuntu -Part I

$
0
0

1. ^foo^bar
This Ubuntu command helps to modify the last run command. This avoids the retyping of the whole command again and is helpful when typo’s occurs in a long command. The syntax of the command is ^typo_code^actual_code
Example:
pint localhost -c 3

greetz@ubuntu:~$ pint localhost -c 3
No command 'pint' found, did you mean:
 Command 'print' from package 'mime-support' (main)
 Command 'pinot' from package 'pinot' (universe)
 Command 'pinq' from package 'qmail' (universe)
 Command 'tint' from package 'tint' (universe)
 Command 'pinto' from package 'pinto' (universe)
 Command 'ping' from package 'iputils-ping' (main)
 Command 'ping' from package 'inetutils-ping' (universe)
 Command 'pinta' from package 'pinta' (universe)
pint: command not found

^pint^ping

greetz@ubuntu:~$ ^pint^ping
ping localhost -c 3
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.023 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.019 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.022 ms
--- localhost ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1998ms
rtt min/avg/max/mdev = 0.019/0.021/0.023/0.004 ms

Note: Carelessly replacing the typo with system commands may be risky.


2. sudo !!
This command can be used in situation where you forgot to specify sudo for the root privileges before the command. sudo !! command recalls the last command and runs it with sudo permissions.
Example:
apt-get update

greetz@ubuntu:~$ apt-get update
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

sudo !!

greetz@ubuntu:~$ sudo !!
sudo apt-get update
[sudo] password for greetz: 
Get:1 http://security.ubuntu.com trusty-security InRelease [65.9 kB]
Ign http://extras.ubuntu.com trusty InRelease 
......

3. look
The look command can be a handy option to check for words from an English dictionary in case you have forgotten the spellings.
Example:
look geek

 
greetz@ubuntu:~$ look geek
geek
geek's
geekier
geekiest
geeks
geeky

4. tree
This command helps to list the current directory structure in a tree format. You have to  first install the package ‘tree‘ (sudo apt-get install tree) in order to use this command.
Example:
tree

greetz@ubuntu:~$ tree
.
├── Desktop
├── Documents
│   ├── greetz to geeks.docx
│   └── New User Manual.docx
├── Downloads
├── examples.desktop
├── Music
├── Pictures
├── Public
├── Templates
└── Videos
8 directories, 3 files

5. ss
The ss command is a very useful and faster command which gives the socket statistics. It is a substitute for the netstat command.
Example:
ss

greetz@ubuntu:~$ ss
Netid State Recv-Q Send-Q          Local Address:Port    Peer Address:Port 
u_str ESTAB 0      0         @/tmp/.X11-unix/X0   17472          *   17471 
u_str ESTAB 0      0                         *    16670          *   16671 
u_str ESTAB 0      0      @/tmp/dbus-VQpvce49KE   17336          *   17335 
..........

Viewing all articles
Browse latest Browse all 10

Trending Articles