• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

Basic Linux Command Line Tricks

141

Basic Linux Command Line Tricks

This tutorial will cover the basic Linux command tricks that can be used in terminal for your own uses.

To use the midnight command

The midnight command is used to run the commands graphically. Before using midnight commander you should install mc (midnight commander) package using yum command.

[root@linuxhelp Desktop]# yum install mc

To launch midnight commander

Execute the following command to launch the midnight commander.

[root@linuxhelp Desktop]# mc

desktop

To create directory in mc shell press mkdir option

directory_name

mydir_page

In the above image you can see the options at the bottom of the mc shell.

To edit your file

To edit your file select that particular file and now click edit option.

edit_file
areassavefile

To delete file or directory

To delete file or directory select that particular file or directory now click delete option.

deletefile
To quit mc shell press quit option and press yes.
delete_file_1

To display information about known users

To display information about known users in the system by using lslogins.

[root@linuxhelp Desktop]# lslogins
UID USER PWD-LOCK PWD-DENY LAST-LOGIN GECOS
0 root 0 0 03:08:39 root
1 bin 0 1 bin
2 daemon 0 1 daemon
3 adm 0 1 adm
4 lp 0 1 lp
5 sync 0 1 sync
6 shutdown 0 1 shutdown
.
.
.
.
497 dovenull 0 1 Dovecot' s unauthorized user
498 saslauth 0 1 Saslauthd user
499 rtkit 0 1 RealtimeKit
500 xguest 0 1 Guest
501 user1 0 0
65534 nfsnobody 0 1 Anonymous NFS User

To search only file in particular location

To search only file in particular location by using find command.

[root@linuxhelp ~]# find /root/Desktop -type f
/root/Desktop/file.txt
/root/Desktop/dir1/my.txt
/root/Desktop/my.txt
/root/Desktop/as
/root/Desktop/dir3/my.txt
.
.
.
.
/root/Desktop/dir2/my.txt
/root/Desktop/mydir
/root/Desktop/googlizer-0.1.tar.gz

To search file type with specific size

To search file type with specific size by using find command.

[root@linuxhelp Desktop]# find . -type f -size 1M
./dir1/my.txt
./dir3/my.txt
./googlizer/README
./googlizer/Makefile
.
.
.
./dir2/my.txt
./mydir
./googlizer-0.1.tar.gz

For more info about find command: https://www.linuxhelp.com/find-command/

To create directory tree

Use mkdir command with -p option to create directory tree.

[root@linuxhelp Desktop]# mkdir -p dir/a/b/c/d/e
[root@linuxhelp Desktop]# tree dir
dir
??? a
??? b
??? c
??? d
??? e

5 directories, 0 files

For more info about mkdir command: https://www.linuxhelp.com/mkdir-command/

Copy the single file into multiple directories

To copy the single file into multiple directories by use xargs command.

[root@linuxhelp Desktop]# echo /root/Desktop/dir1/ /root/Desktop/dir2/ /root/Desktop/dir3/ | xargs -n 1 cp /root/Desktop/my.txt
[root@linuxhelp Desktop]# cd dir1/
[root@linuxhelp dir1]# ls
my.txt
[root@linuxhelp Desktop]# cd dir2/
[root@linuxhelp dir2]# ls
my.txt
[root@linuxhelp Desktop]# cd dir3/
[root@linuxhelp dir3]# ls
my.txt

To remove the bytes or content from the file without deleting the file

Use > followed by the file name to delete only the content of the file.

[root@linuxhelp Desktop]# cat my.txt
qwerty
nokia
moto
sony
samsung
[root@linuxhelp Desktop]# >  my.txt
[root@linuxhelp Desktop]# cat my.txt

For more info about cat command: https://www.linuxhelp.com/cat-command/

To run the Previous Command

To run the command again, press the up key on your keyboard repeat. Instead the history command list all the command below.

[root@linuxhelp Desktop]# history
1 ip route show
2 ssh root@192.168.5.55
3 dig twitter.com
4 vim /etc/ssh/sshd_config
5 service sshd restart
6 ip a
7 vim /etc/ssh/sshd_config
8 iptables -F
9 vim /etc/sysconfig/network-scripts/ifcfg-eth0
.
.
.
100 ps -ef
101 ps -eo user,comm,pid
102 ps -rf | grep httpd
103 ps -ef | grep httpd
104 ps -ef | grep nfs
105 ps -ef | grep httpd
106 cd

If you want check particular previous command from history command shell, use below option here am going to execute number 6th command in history shell by using ‘ !’ factorial symbol.

[root@linuxhelp Desktop]# !6
ip a
1: lo: < LOOPBACK,UP,LOWER_UP>  mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: < BROADCAST,MULTICAST,UP,LOWER_UP>  mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:dd:23:8c brd ff:ff:ff:ff:ff:ff
inet 192.168.5.82/24 brd 192.168.5.255 scope global eth0
inet6 fe80::20c:29ff:fedd:238c/64 scope link
valid_lft forever preferred_lft forever
3: virbr0: < BROADCAST,MULTICAST,UP,LOWER_UP>  mtu 1500 qdisc noqueue state UNKNOWN
link/ether 52:54:00:86:7c:3d brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
4: virbr0-nic: < BROADCAST,MULTICAST>  mtu 1500 qdisc noop state DOWN qlen 500
link/ether 52:54:00:86:7c:3d brd ff:ff:ff:ff:ff:ff

To use shutdown command

If you want to shutdown your system with specified time duration, then follow the below command.

[root@linuxhelp Desktop]# shutdown 04:16

Now your system will be shutdown at time 04:16.

If you want to shut down your system after 15 minutes from your current time the follow below commands.

[root@linuxhelp Desktop]# shutdown +15

If you want to shut down your system immediately you should use below command.

[root@linuxhelp Desktop]# shutdown now

For more info about shutdown command: https://www.linuxhelp.com/shutdown-command/

Tags:
owen
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

How can I install mc in fedora ?

A

Please use "dnf install mc" to install in Fedora.

Q

Is there any aleternate way other than "lslogins"

A

Prefer using "who" command "aureport" are some of the useful commands

Q

How to execute commands execyed in history directly?

A

Exclamatory mark followed by the command number in history status

Q

What time format is enabled for Shutdown command in Linux?

A

It is based on the Timezone assigned in it

Q

What is the best alternative to find command?

A

Prefer using locate command for finding files.

Related Tutorials in Basic Linux Command Line Tricks

Related Tutorials in Basic Linux Command Line Tricks

FFmpeg Commands in Linux with Examples
FFmpeg Commands in Linux with Examples
Apr 4, 2016
Basic Linux Command Line Tricks
Basic Linux Command Line Tricks
Apr 20, 2016
Useful commands to manage Desktop and Server in Linux - Part 1
Useful commands to manage Desktop and Server in Linux - Part 1
Apr 27, 2016
Useful commands to manage Desktop and Server in Linux - Part 2
Useful commands to manage Desktop and Server in Linux - Part 2
Apr 27, 2016
How to use mkdir, tar and kill commands efficiently in Linux
How to use mkdir, tar and kill commands efficiently in Linux
Apr 19, 2016
Interesting Command Line Tips and Tricks in Linux
Interesting Command Line Tips and Tricks in Linux
Apr 5, 2016
How to run Linux commands every X seconds
How to run Linux commands every X seconds
Mar 25, 2016

Related Forums in Basic Linux Command Line Tricks

Related Forums in Basic Linux Command Line Tricks

CentOS
isaiah class=
pidstat no found
May 28, 2018
Basic Commands
FerTah class=
Command sort or uniq
Apr 10, 2019
Windows
Aditya class=
Net view usage in Windows 10
Jul 31, 2019
Basic Commands
gibbson class=
How to install locate command
Aug 25, 2018
Basic Commands
yousuf class=
How to check history command with time
Aug 25, 2018
Basic Commands
raven class=
Basic Commans are not working
Dec 29, 2017
CentOS
muhammad class=
list files on created time
Jun 12, 2018
Basic Commands
elijah class=
How to List only Directories from the Current Location in Linux
Dec 18, 2019
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help keel johnston ?
Unhide the folders on windows Explorer

Give any solutions to unhide folder using command prompt?

forum3

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.