index   prev   next RISC OS Notes

Linux

"I don't like GUIs" Linus Torvalds Finland Security is in the linux dna - learn to dance with it From Ma Bell labs in 1969 - multics > unix > minix > linux

alphabetical list of bash commands
structured list of commands


# what am I? who am I? where is it?

a[Tab][Tab] list all commands beginning `a' apropos net list commands related to net apt install xyz (sudo) get and install xyz blkid info about block devices cat /etc/os-release linux version info cat /proc/version linux version info cat /etc/passwd info on all users cat /proc/cpuinfo rpi model info clear clears screen you can still scroll back compgen -c | sort sorted list of all bash commands ctrl-c or ctrl-d interrupt process (eg ping) cd /etc;ls multiple commands separated by semi-colons declare show env vars ** Warning lots of stuff df display free df -h show devices (h is for human) dig riscpc dnsutils *install dmesg msgs from /var/log relative to most recent boot echo $UID|$HOME|$PATH display system variables env displays environment variables - $NAMES find /etc/*ftp* search live system finds string after path free show memory free -m ( megabytes) history | fc -l list commands eg use !198 to run command from list hostname name of machine eg hp-lubuntu hostname -I ip address id user and group info ifconfig -a ip address mac address journalctl show system journal - big locate *config install; chmod 755 <userhome>; sudo updatedb ls list current directory contents ls -ld show permissions for current directory ls -lp list full date and times, add / to dir names --time-style=long-iso ls -lishaR list all recursive *** may be lots ls /bin list your system commands: lsblk partitions show lsusb list USB devices man hostname online manuals neofetch essential raspberry pi info - *install nmap -sn 192.168.1.0/24 show all devices on subnet passwd -Sa (sudo) show password status of all users pwd show present working directory $PWD PS1="\u\w >" user\path > terminal prompt string pstree show processes as tree diagram raspi-config (sudo) show change start up parms source xxx executes bash script shutdown -r now (sudo) shutdown and reboot now top show active tasks live process display top -d 5 -n 3 (d seconds, n iterations) tree tree structure dir listing umount /dev/sda1 device unmount uname -a sytem info version numbers which ls returns path of executable who users logged on whoami current user whereis hostname binary, source and man locations for hostname
 

# some more linux cmds

arecord list hard devices audio arecord -l cat foo cp copy cp xxx ~/yyy ( current to home) du -h directory size file foo for jpgs shows resolution md make directory (or path) md xdir/ydir (creates both) mv foo ~ - moves file to home dir passwd chg password of current user poweroff reboot rm -vfr food remove dir food and its contents stat foo file info touch foo create empty file foo useradd create new account visudo edit sudoers permissions file Pipe command to another history | grep "nano" Redirect std out to file history > yyy grep "nano" yyy Nano editor ˆg display help text

# access permissions

3 x 3 - 9 bits or 3 octal values or 10 letters where: first position is object type (d,l,-) for (directory,link,file) r is read yes, w is write yes, x is execute yes no is shown by a dash (-) Eg drwxr-xr-x 755 d directory r read owner yes w write owner yes x xecute owner yes r read group yes - write group no x xecute group yes r read other yes - write other no x xecute other yes sudo chown john filefoo file change owner sudo chmod ugo+rwx foo file change permissions sudo chmod -R ugo+rwx * sudo chmod -R a-x * remove execute

#directories

linux forward slash / ms backslash \ directory symbols / root directory eg cd / ~ (tilde character) My home directory (normally /home/my_login_name). "cd" alone is equivalent to "cd ~". . (dot) Current directory. Eg ./my_program executes file "my_program" in current work dir .. (two dots) Directory parent to the current one. - (dash) changes to previous directory location (equiv to $OLDPWD) pwd shows current Working Directory / root bin/ essential software, user cmds, eg ls, sort,.. boot/ bootable kernel and boot loader configs grub dev/ virtual files allowing access points to devices etc/ system global config files /etc/init/vsftpd.conf /etc/vsftp.conf home/ user directories eg john/ lib/ libraries proc/ info about sys resources, stats, eg cpuinfo root/ home directory for root acount sbin/ admin cmds and daemons for root user /sbin/vsftpd srv/ servers? has empty ftp dir sys/ related to proc/ usr/ user doc, user admin, software, sys libraries tmp/ temporary files for apps var/ sys data, app data logs, spool /var/log/vsftpd.log

# running apps

To run app or script from cmd line it must be in path or explicitly referenced eg if it is in current dir ./jrscript.sh (note .sh suffix required) ( echo $PATH - all directories with commands you can run) Note - Name of app may not be same as the command to run it. eg. to run Leafpad use "leafpad filename" navigate to /usr/bin to find these executables Run from >>Start menu. eg start to type torus - first matching entry pops up -click to start

# Scripts aka shell scripts (.sh)

use a text editor to create file (leafpad or gedit) first line should be:- #!/bin/sh save with filetype sh eg jrscript.sh set permissions to allow execution sample script:- #!/bin/sh echo "hello world"

# VNC Server on Raspberry Pi

builtin - enable via >>preferences >Raspberry Pi Configuration >Interfaces Authentication for RISC OS using GUI - >> V2 > Options ... Security ... Encryption > prefer off Authentication > VNC password Users and Permissions Standard user enter password OK Change Desktop bacground to plain FIX broken headless HDMI configuration (pre Bullseye):- >sudo nano /boot/config.txt add:- dtoverlay=vc4-kms-v3d,nocomposite

SSH on Raspberry Pi

Enable SSH Server in Raspberry Pi Configuration ssh clients store keys per ip address in known_hosts file if key changes on Server, Client will reject logon:- WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! To fix: on client computer remove keys for that ipadddr ssh-keygen -R 192.168.1.98

Libcamera on Raspberry Pi 3B+

***FIX for camera apps not working*** sudo raspi-config >advanced options >enable glamor graphic acceleration reboot

SMB Managing Samba

(setup SMB see pimylifeup.com) sudo apt install samba change hostname from raspberrypi to eg raspi-v SMB Lnx Configuration File Reference Manual https://www.samba.org/samba/docs/current/man-html/smb.conf.5.html EDIT Configuration File sudo nano /etc/samba/smb.conf SAMBA logs log file = /var/log/samba/log.%m eg log.smbd - smbd daemon status daemon smbd ready to serve log.nmbd - nmbd daemon status failed to register my name RASPBERRYPI on 192.168.1.98 query name response from ...27 log.192.168.1.98 empty CHECK SYNTAX OF SMB.CONF testparm CHECK WHO IS LOGGED ON sudo smbstatus RESTART SAMBA:- sudo systemctl start smbd sudo systemctl restart smbd.service VIEW LIST OF SHARES - needs install password - raspberry smbclient -L localhost pi@raspberrypi:~ $ smbclient -L localhost Unable to initialize messaging context Enter WORKGROUP\pi's password: Sharename Type Comment --------- ---- ------- print$ Disk Printer Drivers piroot Disk the whole pie pidesk Disk home pi desktop IPC$ IPC IPC Service (Samba 4.9.5-Debian) pi Disk Home Directories Reconnecting with SMB1 for workgroup listing. Server Comment --------- ------- sudo Workgroup Master --------- ------- WORKGROUP RASPBERRYPI pi@raspberrypi:~ $

SMB /etc/samba/smb.conf

[homes] create mask = 0775 directory mask = 0775 [piroot] comment = the whole pie path = / [pidesk] comment = home pi desktop path = /home/pi/Desktop read only = no create mask = 0777 directory mask = 0777 Guest ok = yes

© JR 2022