[Linux] Tips & Tricks.

Abhishek Rawal
@abhishek-fg9tRh โ€ข Oct 22, 2024

This Thread is dedicated for tips & tricks of Linux. Gather up & share some tricks & tips for linux.
I will roll the dice first.

Counting The Number Of Files In A Directory :
- 'cd' to the desire directory
- Then type :

 echo * | wc -w 

Check On The Date & time Computer Was Re-booted :
- go to root & type :

 last reboot 

- To know date & time system was booted, go to root & type :

 who -b 

Find Files & Move It With Single Command :

 find Name_Of_Directory -type f -iname "*.pdf" -exec mv {} Location_Where_You_Wanna_Copy \; 

example :

 find /abc/ebooks -type f -iname "*.pdf" -exec mv {} /xyz/books \; 

The above example shows that, from directory /abc/ebooks all .pdf extension files will be moved to /xyz/books directory.

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Nayan Goenka

    @nayan-Dhpt4N • Aug 10, 2013

    I already made a thread regarding a lot of commands. Still if you need to make a complete directory, you can check it out here. It is almost a<a href="https://ss64.com/bash/" target="_blank" rel="nofollow noopener noreferrer">An A-Z Index of the Linux command line - SS64.com</a>.

  • Abhishek Rawal

    @abhishek-fg9tRh • Aug 10, 2013

    Nayan GoenkaI already made a thread regarding a lot of commands. Still if you need to make a complete directory, you can check it out here. It is almost a<a href="https://ss64.com/bash/" target="_blank" rel="nofollow noopener noreferrer">An A-Z Index of the Linux command line - SS64.com</a>.

    Tips & Tricks != Commands.

  • Abhishek Rawal

    @abhishek-fg9tRh • Aug 10, 2013

    Format Drive From Terminal :

    (We will format USB drive in this)
    - Insert USB drive in USB slot.
    - Open Terminal & type

     df 

    - This will display directory path of various drives. Check image below :

    Screenshot from 2013-08-11 06:56:33

    The highlighted directory i.e /dev/sdc1 is the flash-drive which I wanna format.

    - Unmount the flash drive first by typing :

     sudo umount <path> 

    here in this example it will be something like

     sudo umount /dev/sdc1 

    - Now to format the flash drive to ext4, type :

     sudo mkfs.ext4  -n 'CrazyEngineers' -l /dev/sdc1 

    You can format drive in another formats using : mkfs.ext2, mkfs.ext3, mkfs.ext4, mkfs.vfat, mkfs.msdos, mkfs.minix etc. etc.

    - Type df again to check the result :

    Screenshot from 2013-08-11 07:08:05

    ๐Ÿ‘

  • Manish Goyal

    @manish-r2Hoep • Aug 13, 2013

    Create a tunnel between server and you localserver to access remote server resources through following command

    ssh -N -L 3336:127.0.0.1:3306 -i <option private KEY> username@servername.com
    

    Above command will simply map you local server port 3336 to 3306 , with this you can access remote Mysql (3306) through local 3336 port