Linux Commands [Author’s experience]

1.Format SD card

$ df

$ sudo umount /dev/sdc1

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

http://www.unixmen.com/how-to-format-usb-drive-in-the-terminal/

2. Unzip

$ unzip file.zip

http://askubuntu.com/questions/86849/how-to-unzip-a-zip-file-from-the-terminal

3. Write to SD card/driver

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

https://wiki.linaro.org/Boards/MX6QSabreLite

4. Decompress tar.gz

$ tar -xzvf advancemame-1.2.tar.gz 

http://www.element14.com/community/community/designcenter/single-board-computers/sabrelite/blog/2014/04/09/using-advance-mame-to-play-arcade-style-games-on-sabre-lite-imx6

5. Extract tar.xz

$ tar -xvfJ advancemame-1.2.tar.xz

http://stackoverflow.com/questions/12298368/how-to-extract-tar-xz-files-in-linux

6. Copy/paste from and to terminal/shell

CTRL+SHIFT+C/V

7. Remove/ Delete file from terminal

$ rm <file-name>

http://www.cyberciti.biz/faq/howto-linux-unix-delete-remove-file/

8. Rename file from terminal

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

http://www.cyberciti.biz/faq/linux-rename-file/

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 name.zip folder/ -x "*.DS_Store"
zip -evr name.zip 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: https://unsplash.com/photos/2zDXqgTzEFE

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 *