Unix
Some unix command and other ressources, in case of.
Cheatsheet:
Help:
- man {command}: Display manual for command
- {command} --help: Display quick help for command (sometime -h does work also)
Directory navigation:
- cd {path}: Go to path
- cd ~: Go to home directory
- cd ..: Go up one directory
- pwd: Print working directory
File listing:
- ls {path}: List file(s) in {path} (current directory if no path specified)
- ls -l: List files with details (date, size, permissions)
- ls -a: List all files, including hidden files
- ls -R: Recursively list subdirectories
View file content:
- cat {fileName}: Display the content of fileName
- tail {fileName}: Display the last lines of fileName (usefull for long files)
Files and directories manipulation:
- touch {fileName}: Create an empty file called fileName
- echo "some text" > {fileName}: Create (or overwrite) a fileName with content "some text"
- echo "some text" >> {fileName}: Append "some text" to the end of fileName
- mkdir {directoryName}: Create a directory called directoryName
- mkdir -p: Create chain directory (e.g. mkdir -pv dir1/dir2/dir3)
- mv {fileName} {newFileName}: Rename fileName to newFileName
- cp {fileName} {newFileName}: Copy fileName in newFileName
- cp -r {directoryName} {newDirectoryName}: Copy directoryName in newDirectoryName
- rm {fileName}: Delete fileName
- rm -r {directoryName}: Delete directoryName
Files and directories permissions:
- chown {user}:{group} {fileName}: Change owner of fileName to user:group
- chmod {permissions} {fileName}: Change permissions of fileName to permissions
Process management:
- ps -aux: List all processes
- kill {pid}: Kill process with id pid
- kill -9 {pid} : Force kill process with id pid
Various
- where {command}: Display location(s) of command
- which {command}: Display currently used path of command
- clear: Clear terminal screen
General considerations:
Optional flags can be combined.
ls -la: List all files with details
Command can be chained (pipe).
ls -la | grep "file.txt": List all files with details and filter for file.txt