Table of contents
Open Table of contents
Article body
Before we begin:
I think knowing Linux helps us manage our projects better as developers.
What some of the directories under the Linux root directory are for:
bin ----system commands that ordinary users can run; sbin ----system commands that only administrators can run
tmp ----temporary files; home ----home directories for ordinary users;
etc ----system configuration files; usr ----system software resources; var ----various system-related files;
mnt ----a location for mounting other filesystems; dev ----hardware device files.
Those are the main directories covered here. Knowing their purposes helps us understand problems and identify the paths involved.
Some Linux commands:
Most frequently used: cd DIRECTORY_NAME ----enter that directory.
cd ../ ----go up one directory
cd / -----go to the root directory
zip -r (recursive) -m (remove the original files after archiving) ARCHIVE_NAME.zip SOURCE_NAME; create an archive in the specified directory without retaining the source files. Example: zip -r -m ../ocproject.zip ocproject
zip -r PATH/ARCHIVE_NAME.zip SOURCE_NAME; create an archive in the specified directory and retain the source files. Example: zip -r ../ocproject.zip ocprject
unzip ARCHIVE_NAME.zip -d (extract into a specific directory); example: unzip ocproject.zip -d coding/ extracts the archive into the coding directory under the current directory.
tar -zxvf ARCHIVE_NAME.tar.gz SOURCE_NAME -C (extract into a specific path); example: tar -zxvf ocproject.tar.gz -C coding/
tar -zcvf PATH/ARCHIVE_NAME.tar.gz SOURCE_NAME; example: tar -zcvf ../ocproject.tar.gz ocproject
tar -jxvf ARCHIVE_NAME.tar.bz2 SOURCE_NAME -C (extract into a specific path); example: tar -zxvf ocproject.tar.bz2 -C coding/
tar -jcvf PATH/ARCHIVE_NAME.tar.bz2 SOURCE_NAME; example: tar -zcvf ../ocproject.tar.bz2 ocproject
Use clear to clear the terminal in Linux. I usually use the shortcut ---ctrl+L.
In the Linux command line, ---ctrl+a moves to the beginning of a command, and ----ctrl+e moves to the end.
Then there is the frequently used ls command:
We usually use ls simply to see what is in a directory, but its other options are useful too:
ls -a DIRECTORY; show all files, including hidden files
ls -l DIRECTORY; show detailed information, including the important read and write permissions for the owner, the group, and other users. These permissions matter.
du -sh FILE_NAME; show the file’s size