#MOC # Linux ## Contents - [[#General Information|General Information]] - [[#Management|Management]] - [[#Management#Network Management|Network Management]] - [[#Management#Service and Process Management|Service and Process Management]] - [[#Management#Remote Access|Remote Access]] - [[#Management#Misc|Misc]] - [[#File System|File System]] - [[#Terminal|Terminal]] - [[#Terminal#Scripting|Scripting]] - [[#Tools|Tools]] - [[#Specific Distros|Specific Distros]] - [[#.NET Gotchas|.NET Gotchas]] ## General Information For general information about how linux is structured (including file system hierarchy) see [[Linux Fundamentals - Linux Structure]]. ## Management ### Network Management For information about basic tools for network management see [[Linux Fundamentals - Network Configuration]]. If you use Docker, the netshoot container is a well rounded set of diagnostic tools that can be used for troubleshooting. See [[Network Troubleshooting Using Netshoot]]. For setting up the firewall see [[Linux Fundamentals - Firewall Setup]]. For information about other OS-level security tools see [[Linux Fundamentals - Linux Security]]. To configure different hostnames for different adapters see [[Different Host Names for Different Network Adapters on Linux]]. ### Service and Process Management For information about basic tools for process and service management see [[Linux Fundamentals - Service and Process Management]]. Information about the various ways to schedule tasks can be found here: [[Linux Fundamentals - Task Scheduling]]. If you're using `crontab`, the following provides a good summary of `crontab` management commands: [[How to List, Display, & View All Current Cron Jobs in Linux]]. To view a list of open sockets use `ss -tln` (`-n` will disable service name resolution, `-t` will show only TCP). Alternatives: `netstat -tulnp` `lsof -iTCP -sTCP:LISTEN -n -P` ^e2xlsy To see a list of all running processes use `ps aux` - `a` is for all users - `u` displays user-oriented format - `x` includes processes without a terminal `disown` will allow you to disown a job. You can then reclaim it in another terminal using [reptyr](https://github.com/nelhage/reptyr). Tools: ![[#^mndily]] ### Remote Access For recommendations on setting up an SSH server see [[SSH#SSH Server Setup]]. For RDP see [[RDP]]. ![[Linux#^zk2vh1]] ### Misc - For information about `nixpkgs` and the nix package manager see [[Nix]]. - For general information about logs files and their locations see [[Linux Fundamentals - System Logs]]. - For a breakdown of user management commands see [[Linux Fundamentals - User Management]]. - For file permissions see [[Linux Fundamentals - Permission Management]]. - [[Linux Fundamentals - System Information]] provides a nice overview of commands that can be used to gather information about the current system, user, etc. - `lsb_release -a` will output OS info - `uname -a` will output hardware info ## File System For a basic overview of the linux file system hierarchy see [[Linux Fundamentals - Linux Structure#File System Hierarchy]]. For information about the various kinds of file partitions, and info on mounting them (both manually and at startup) see [[Linux Fundamentals - File System Management]]. For more info about auto-mounting partitions see [[Auto-Mounting Drives on Linux]]. For partition management see [[Linux Partition Management]]. For mounting HFSPlus partitions see [[Mounting HFSPlus on Linux]], and to mount Windows BitLocker drives see [[Using Dislocker to Open BitLocker Drives on Linux]]. For commands that will show disk usage see [[Linux Command Line Utilities for Evaluating Disk Usage]]. For a breakdown of various tools that can be used to search for files see [[Linux Fundamentals - Find Files and Directories]]. For file permissions see [[Linux Fundamentals - Permission Management]]. Tools: ![[Linux#^mc7m01]] ## Terminal For an overview about the various text manipulation tools on Linux see [[Linux Fundamentals - Filter Contents]]. For redirecting terminal output to files, and info about standard streams see [[Linux Fundamentals - File Descriptors and Redirections]]. For terminal shortcuts see [[Linux Fundamentals - Shortcuts]]. For configuring ZSH see [[ZSH Configuration]]. For a description of the various ways to set environment variables see [[Setting Environment Variables on Linux]]. For helper tools see [[#Tools]] section. See [[Linux Fundamentals - Getting Help]] for resources if/when you get stuck. AI can be of huge help too, especially if integrated into terminal (e.g. Warp). ### Scripting Scripts need to start with the [[Shebang (Unix) - Wikipedia|Shebang]], eg `#!/bin/sh` [.bashrc generator](http://bashrcgenerator.com/) and [Powerline](https://github.com/powerline/powerline) are tools that can be used to customize the shell. Assorted troubleshooting bits and pieces: - Some Linux distributions (think Docker) have issues with scripts that have carriage returns. These scripts that lead to strange 'File Not Found' errors. Clean them up! ## Tools [[Docker]] | [[Nmap]] | [[Tmux]] [[Restic]] is my **backup tool** of choice across operating systems. [[Linux Fundamentals - Backup and Restore]] provides an overview of various linux-specific tools that can be used for backup including [[rsync]], which is useful when transferring large files between computers in general. For a good breakdown of various **remote desktop** and protocols see [[Linux Fundamentals - Remote Desktop Protocols in Linux]]. RustDesk is a cross-platform tool that should be your go-to solution. ![[RDP#^r1znwe1]] ![[RDP#^r1znwe]] ^zk2vh1 **File system tools:** `fd` is a better version of `find`, [[Linux nnn Terminal File Manager|nnn file manager]]. ^mc7m01 **File editor:** `micro` (to install run `curl https://getmic.ro | sudo bash`) **[`bat`](https://github.com/sharkdp/bat) is a better `cat`** `btop` and `vtop` are **better versions of `top`**. ^mndily **TUIs:** `lazygit` and `lazydocker` **Accessing web resources:** HTTPie is a good alternative for Postman, [[cURL]], [[wget]], [[xh]]. **To open a port on the current machine and forward traffic to another use `socat`**. `fork` causes it to keep listening (once a connection arrives a new process is forked): ^p4xt6p ```sh sudo socat TCP-LISTEN:8080,fork TCP:<IP>:80 ``` ^lqkkxm **File transfer tools:** [[Python Web Server]], [[Impacket#`smbserver`]], [[FTP]] ## Specific Distros See [[Raspberry Pi]] for Raspbian. See [[Nix]] for NixOS. ## .NET Gotchas Unlike on Windows, 32bit applications cannot run on 64bit architectures (at least in some cases). Starting a .NET app compiled for 64bit on 32bit OS can lead to strange errors like 'File Not Found' even though the executable is there.