Do not speak Portuguese? Translate this site with Google or Bing Translator
Linux Introduction Notes

Posted on: July 28, 2023 09:50 AM

Posted by: Renato

Categories: linux Dicas unix

Views: 179

Linux Introduction Notes and Course 🐧

Free Course (in Portuguese) ~> https://youtube.com/playlist?list=PLPqoPgWuohm5fVg0n0COJFXHktVzqwDDF

Filesystem Hierarchy Standard

The Filesystem Hierarchy Standard (FHS) is a reference describing the conventions used for the layout of a UNIX system. It has been made popular by its use in Linux distributions, but it is used by other UNIX variants as well

Directory structure

In the FHS, all files and directories appear under the root directory /, even if they are stored on different physical or virtual devices. Some of these directories only exist on a particular system if certain subsystems.

/
  • Primary hierarchy root and root directory of the entire file system hierarchy.
/bin
  • Essential command binaries that need to be available in single-user mode, including to bring up the system or repair it, for all users (cat, ls, cp).
/boot
  • Boot loader files (kernels, initrd).
/dev
  • Device files (/dev/null, /dev/disk0, /dev/sda1, /dev/tty, /dev/random).
/etc
  • Host-specific system-wide configuration files. There has been controversy over the meaning of the name itself. In early versions of the UNIX Implementation Document from Bell labs, /etc is referred to as the etcetera directory, as this directory historically held everything that did not belong elsewhere (however, the FHS restricts /etc to static configuration files and may not contain binaries).
/home
  • Users' home directories, containing saved files, personal settings, etc.
/lib
  • Libraries essential for the binaries in /bin and /sbin.
/media
  • Mount points for removable media such as CD-ROMs.
/mnt
  • Temporarily mounted filesystems.
/opt
  • Add-on application software packages.
/proc
  • Virtual filesystem providing process and kernel information as files. In Linux, corresponds to a procfs mount. Generally, automatically generated and populated by the system, on the fly.
/root
  • Home directory for the root user.
/run
  • Run-time variable data: Information about the running system since last boot, currently logged-in users and running daemons. Files under this directory must be either removed or truncated at the beginning of the boot process, but this is not necessary on systems that provide this directory as a temporary filesystem (tmpfs).
/sbin
  • Essential system binaries (fsck, init, route).
/srv
  • Site-specific data served by this system, such as data and scripts for web servers, data offered by FTP servers, and repositories for version control systems.
/sys
  • Contains information about devices, drivers, and some kernel features.
/tmp
  • Directory for temporary files (see also /var/tmp). Often not preserved between system reboots and may be severely size-restricted.
/usr
  • Secondary hierarchy for read-only user data; contains the majority of (multi-)user utilities and applications. Should be shareable and read-only.
/var
  • Variable files: files whose content is expected to continually change during normal operation of the system, such as logs, spool files, and temporary e-mail files.

Linux commands

Directory Manipulation Commands in Linux

  • pwd
    • Get the full path of the current working directory.
  • cd -
    • Navigate to the last directory you were working in.
  • cd ~
    • or just cd Navigate to the current user’s home directory.
  • cd ..
    • Go to the parent directory of current directory (mind the space between cd and ..)

Listing Files Inside a Directory

  • ls -l
    • List the files and directories in the current directory in long (table) format (It is recommended to use -l with ls for better readability).
  • ls -ld
    • dir-name List information about the directory dir-name instead of its contents.
  • ls -a
    • List all the files including the hidden ones (File names starting with a . are hidden files in Linux).
  • ls -F
    • Appends a symbol at the end of a file name to indicate its type (* means executable, / means directory, @ means symbolic link, = means socket, | means named pipe, > means door).
  • ls -lt
    • List the files sorted by last modified time with most recently modified files showing at the top (remember -l option provides the long format which has better readability).
  • ls -lh
    • List the file sizes in human readable format.
  • ls -lR
    • Shows all subdirectories recursively.
  • tree
    • Will generate a tree representation of the file system starting from the current directory.

File or Directory - Create, Copy and Remove Commands in Linux

  • cp -p source destination
    • Will copy the file from source to destination directory. -p stands for preservation. It preserves the original attributes of file while copying like file owner, timestamp, group, permissions etc.
  • cp -R source_dir destination_dir
    • Will copy source directory to specified destination recursively.
  • mv file1 file2
    • In Linux there is no rename command as such. Hence mv moves/renames the file1 to file2.
  • rm -i
    • filename Asks you before every file removal for confirmation. IF YOU ARE A NEW USER TO LINUX COMMAND LINE, YOU SHOULD ALWAYS USE rm -i. You can specify multiple files.
  • rm -R dir-name
    • Will remove the directory dir-name recursively.
  • rm -rf dir-name
    • Will remove the directory dir recursively, ignoring non-existent files and will never prompt for anything. BE CAREFUL USING THIS COMMAND! You can specify multiple directories.
  • rmdir dir-name
    • Will remove the directory dir-name, if it’s empty. This command can only remove empty directories.
  • mkdir dir-name
    • Create a directory dir-name.
  • mkdir -p dir-name/dir-name
    • Create a directory hierarchy. Create parent directories as needed, if they don’t exist. You can specify multiple directories.
  • touch filename
    • Create a file filename, if it doesn’t exist, otherwise change the timestamp of the file to current time.

File or Directory - Permissions and Groups Commands

  • chmod < specification > filename
    • Change the file permissions. Specifications = u user, g group, o other, + add permission, - remove, r read, w write, x execute.
  • chmod -R < specification > dir-name
    • Change the permissions of a directory recursively. To change the permission of a directory and everything within that directory, use this command.
  • chmod go=+r myfile
    • Add read permission for the owner and the group.
  • chmod a +rwx myfile
    • Allow all users to read, write or execute myfile.
  • chmod go -r myfile
    • Remove read permission from the group and others.
  • chown owner1 filename
    • Change ownership of a file to user owner1.
  • chgrp grp_owner filename
    • Change primary group ownership of file filename to group grp_owner.
  • chgrp -R grp_owner dir-name
    • Change the primary group ownership of directory dir-name to group grp_owner recursively. Use this command to change group ownership of a directory and everything within that directory.
Reference

2

Share

Donate to Site


About Author

Renato

Developer

Add a Comment
Comments 0 Comments

No comments yet! Be the first to comment

Blog Search


Categories

OUTROS (15) Variados (109) PHP (127) Laravel (154) Black Hat (3) front-end (28) linux (110) postgresql (37) Docker (25) rest (5) soap (1) webservice (6) October (1) CMS (2) node (7) backend (13) ubuntu (54) devops (25) nodejs (5) npm (2) nvm (1) git (8) firefox (1) react (6) reactnative (5) collections (1) javascript (6) reactjs (7) yarn (0) adb (1) Solid (2) blade (3) models (1) controllers (0) log (0) html (2) hardware (3) aws (14) Transcribe (2) transcription (1) google (4) ibm (1) nuance (1) PHP Swoole (5) mysql (28) macox (4) flutter (1) symfony (1) cor (1) colors (2) homeOffice (2) jobs (3) imagick (2) ec2 (1) sw (1) websocket (1) markdown (1) ckeditor (1) tecnologia (14) faceapp (1) eloquent (14) query (3) sql (36) ddd (3) nginx (9) apache (4) certbot (1) lets-encrypt (3) debian (11) liquid (1) magento (2) ruby (1) LETSENCRYPT (1) Fibonacci (1) wine (1) transaction (1) pendrive (1) boot (1) usb (1) prf (1) policia (2) federal (1) lucena (1) mongodb (4) paypal (1) payment (1) zend (1) vim (3) ciencia (6) js (1) nosql (1) java (1) JasperReports (1) phpjasper (1) covid19 (1) saude (1) athena (1) cinnamon (1) phpunit (2) binaural (1) mysqli (3) database (37) windows (6) vala (1) json (2) oracle (1) mariadb (4) dev (12) webdev (24) s3 (4) storage (1) kitematic (1) gnome (2) web (2) intel (3) piada (1) cron (2) dba (13) lumen (1) ffmpeg (2) android (2) aplicativo (1) fedora (2) shell (4) bash (3) script (3) lider (1) htm (1) csv (1) dropbox (1) db (3) combustivel (2) haru (1) presenter (1) gasolina (1) MeioAmbiente (1) Grunt (1) biologia (1) programming (21) performance (3) brain (1) smartphones (1) telefonia (1) privacidade (1) opensource (3) microg (1) iode (1) ssh (3) zsh (2) terminal (3) dracula (1) spaceship (1) mac (2) idiomas (1) laptop (2) developer (36) api (4) data (1) matematica (1) seguranca (2) 100DaysOfCode (9) hotfix (1) documentation (1) laravelphp (9) RabbitMQ (1) Elasticsearch (1) redis (2) Raspberry (4) Padrao de design (4) JQuery (1) angularjs (4) Dicas (36) Kubernetes (2) vscode (2) backup (1) angular (3) servers (2) pipelines (1) AppSec (1) DevSecOps (4) rust (1) RustLang (1) Mozilla (1) algoritimo (1) sqlite (1) Passport (1) jwt (4) security (2) translate (1) kube (1) iot (1) politica (2) bolsonaro (1) flow (1) podcast (1) Brasil (1) containers (2) traefik (1) networking (1) host (1) POO (2) microservices (2) bug (1) cqrs (1) arquitetura (2) Architecture (3) sail (3) militar (1) artigo (1) economia (1) forcas armadas (1) ffaa (1) autenticacao (1) autorizacao (2) authentication (4) authorization (2) NoCookies (1) wsl (4) memcached (1) macos (2) unix (2) kali-linux (1) linux-tools (5) apple (1) noticias (2) composer (1) rancher (1) k8s (1) escopos (1) orm (1) jenkins (4) github (5) gitlab (3) queue (1) Passwordless (1) sonarqube (1) phpswoole (1) laraveloctane (1) Swoole (1) Swoole (1) octane (1) Structurizr (1) Diagramas (1) c4 (1) c4-models (1) compactar (1) compression (1) messaging (1) restfull (1) eventdrive (1) services (1) http (1) Monolith (1) microservice (1) historia (1) educacao (1) cavalotroia (1) OOD (0) odd (1) chatgpt (1) openai (3) vicuna (1) llama (1) gpt (1) transformers (1) pytorch (1) tensorflow (1) akitando (1) ia (1) nvidia (1) agi (1) guard (1) multiple_authen (2) rpi (1) auth (1) auth (1) auth (1) auth (1) Oh My Zsh (1) Manjaro (1) BigLinux (2) ArchLinux (1) Migration (1) Error (1) Monitor (1) Filament (1) LaravelFilament (1) replication (1) phpfpm (1) cache (1) vpn (1) l2tp (1) zorin-os (1) optimization (1) scheduling (1) monitoring (1) linkedin (1) community (1) inteligencia-artificial (2) wsl2 (1) maps (1) API_KEY_GOOGLE_MAPS (1)

New Articles



Get Latest Updates by Email