Alex's Slip-box

These are my org-mode notes in sort of Zettelkasten style

Unix reference

:ID: 4ac31a1d-cdb1-4722-8215-3ed01414084b

This is a quick reference for some common Unix commands, tools and configuration.

See also Shell tips

# Permissions

See also this cheatsheet for more.

# View file permissions and ownership

ls -l
type user group other
- rwx rw- r--

Type could be d (ie, directory)

# Change permissions

chmod u+rw file

Adds (+), for user (u), read and write (rw) permissions. See chmod --help.

# Change ownership

chown username file
chown username:groupname file
chgrp groupname file

# Groups

# List groups

cmd description
groups list your groups
groups username list a user’s groups
getent group groupname list users in a group
cat /etc/group list all groups on the system

# Manage group membership

Use gpasswd

# User Information

The id utility can provide information like uid, groups, etc. Use a flag to pull out specific information (-u => uid)

id username

Need to restart after changing group membership

# Magic SysRq key

Send low level commands regardless of system state (freeze)

# Repositories (apt)

# Release file expired error

A couple options:

  1. Find another mirror. One that isn’t expired. Or…
  2. Instruct apt to always skip the validity check

    touch /etc/apt/apt.conf.d/99no-check-valid-until && \
    echo 'Acquire::Check-Valid-Until no;' > /etc/apt/apt.conf.d/99no-check-valid-until
    

# Install specific version (if available)

apt-get install something=1.1.1

# Check for available versions

apt-cache policy ruby-full

# Add a repository

First add software-properties-common:

apt-get install -y software-properties-common

Then added the repo:

add-apt-repository ppa:kelleyk/emacs

And update

apt-get update

# File System

The following are just basic examples. There’s a lot you can do with these tools. Use --help or man pages.

# Display file system information

# df

Example: (human-readable)

df -h

# Disk Usage

# du (disk usage)

Example: (human-readable)

du -hs

# Copy files over SSH

# scp

Example: (recursive). This will use remote directories the map to the specified user’s home directory. Enter remote user’s pw when prompted.

scp -r "scp://pi@192.168.68.55/user/dir/path/to/stuff" ~/Downloads

# Make disk image

After attaching the disk you want imaged, use df -h to get the mount point. Then use use the dd utility and specify the imput and output. Example:

sudo dd if=/dev/mmcblk0p2 of=~/myimage.img

There will be no output while the image is made.

# Make a Hexdump

# xxd

xxd -ps /path/to/file | tr -d '\n'

# Devices

See also Pop_os (eg, lsusb, etc)

# Logging

# Boot process

# dmesg

A command line utility to view (among other things) kernel messages regarding hardware devices. Is something going wrong with the boot process, some devices not working? Look at dmesg.

# System logging

/var/log/syslog

# Other logging

Look in /var/log/ directory at all the other log files. Applications will write logs here. For example /var/log/httpd

# SSH

# Allow SSHing onto a system

  1. Install openssh-server. This is configured via systemd to automatically start.
  2. Use ufw to open port 22 (if firewall is active)

Search Results