Linux Commands [Author’s experience]

1.Format SD card

$ df

$ sudo umount /dev/sdc1

$ sudo mkfs.vfat -n 'Ubuntu' -I /dev/sdc1

2. Unzip

$ unzip

3. Write to SD card/driver

$ sudo dd if=<name>.bin of=/dev/sdx bs=4M;  sync

4. Decompress tar.gz

$ tar -xzvf advancemame-1.2.tar.gz

5. Extract tar.xz

$ tar -xvfJ advancemame-1.2.tar.xz

6. Copy/paste from and to terminal/shell


7. Remove/ Delete file from terminal

$ rm <file-name>

8. Rename file from terminal

$ mv <old-filename> <new-filename>

9. check file format

$ file <filename>

10. Decompressed tar.bz2

$ tar -xjvf <filename>.tar.bz2

11. remove folder 

if empty:

$ rmdir <directory>

if non-empty folder

$ rm -rf <directory/folder>

P/s: the folder will be deleted (not all path) 

12. Copy file as root permission

$ sudo cp -r /path/ /destination/

13. Copy file without overwrite

$ cp -n /path/ /destination/

14. Set permission for working in root files

$ sudo chown -R /path/

15. Create symbolic link between 2 folders:

original folder: /home/tientham/original (must be not exist)

target folder: /home/tientham/target    (exist already)

$ mkdir target   (in case there is no "target" folder yet)

$ ln -s /home/tientham/target/ /home/tientham/original

“ln” command will create “original” folder for you.

16. Find a string inside folder

grep -Ril "text_to_find" .

  • i stands for ignore case (optional in your case).
  • R stands for recursive.
  • l stands for “show the file name, not the result itself”.
  • . stands for the folder where you are.

17. Exclude a text from the output using grep
grep -v "text_to_exclude"

18. [MAC-OS] zip folder
zip -vr folder/ -x "*.DS_Store"
zip -evr folder/ -x "*.DS_Store"

19. [MAC-OS] find files given its size
sudo find / -type f -size +100000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'

20. Find a string inside all files under given directory
grep -iRl "your-text-to-find" .



Image source:

About: tientham

Software Engineer, SW Integrator & Mobile , Full Stack Developer

3 thoughts on “Linux Commands [Author’s experience]”

Leave a Reply

Your email address will not be published. Required fields are marked *