웹풀스택 공부 중
Bash 명령어 본문
📂 Directory Commands
pwd: Display the absolute path of the current directory.cd (directory_name): Change to the specified directory.cd ..: Move up one directory (to the parent directory).ls: List all files and directories in the current directory.ls -la: Display detailed information for all files and directories, including hidden files (those that start with.).
🛠️ Directory & File Operations (Create, Move, Delete)
mkdir (directory_name): Create a new directory.rm (file_name): Delete a file or directory.rm -rf (directory_name): Recursively force-delete a directory and its contents.cp (source) (destination): Copy files or directories from the source to the destination.mv (source) (destination)ormv (old_name) (new_name): Move a file (cut and paste) or rename a file.
📄 File Output
touch (file_name): Create a new file.cat (file_name): Display the contents of a file.echo 'txt_to_write' > (file_name): Write text to a file (overwrite if it exists).>: Overwrite the file.>>: Append to the file.
echo: Can be used to view environment variable values, similar toConsole.log.export (ENVIRONMENT_VARIABLE)=(value): Set an environment variable and useechoto confirm it.- This applies only to the session, so to save it, you can use
vi ~/.bashrcto add the export command. - Save with
:wq, then update withsource ~/.bashrcto apply.
- This applies only to the session, so to save it, you can use
head -n 3 (file_name): Display the first 3 lines of a file.tail -n 3 (file_name): Display the last 3 lines of a file.
🔄 Command Chaining
ls | sort | less: Pipe the output of thelscommand intosort, and then pipe that result intolessfor viewing.grep: Search for a specific pattern or regular expression in a string.
🔧 Other Command Modifiers
&&: Perform independent commands (the output of one does not affect the next).;: Execute the next command even if the previous one fails.&: Run the next command concurrently with the previous one.||: Execute the next command only if the previous one fails.
🛠️ Utilities
chmod: Change file permissions.Read (4), Write (2), Execute (1)
Example:
7 = Read + Write + ExecuteExample:
1 = Execute onlyFirst digit: Owner permissions.
Second digit: Group permissions.
Third digit: Other permissions.
Example:
700: Only the owner can read, write, and execute.
tar: Extract files from a TAR archive.sudo: Execute a command with superuser privileges (root access).vi: Text editor.code: VSCode editor.
'웹개발 > 개발자' 카테고리의 다른 글
| 기초 코드 작성 방법 [rule of thumb] (3) | 2024.09.03 |
|---|---|
| Git Zone & Git Flow (0) | 2024.09.03 |
| Git 구조 및 Remote vs Local (0) | 2024.09.01 |
| Git & GitHub (2) | 2024.08.27 |