Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux [2019/02/25 20:25]
paul [CLI Shortcuts]
linux [2019/12/28 23:23] (current)
Line 1: Line 1:
 ====== Linux ====== ====== Linux ======
  
-Linux is a beautiful example of clean engineering. Form follows function. The +Linux is a beautiful example of clean engineering. Form follows function and 
-following is a collection of notes.+function follows coherent thoughts. The following is a collection of notes. 
 + 
 +===== Adding passwordless users ===== 
 + 
 +To add a sudo user that doesn't have a password you have to first add a user with a password, and then delete the password. This activates the password. 
 + 
 +<code bash> 
 +sudo adduser usernameyoulike 
 +# give the user any temp password 
 +# the following command removes the password 
 +sudo passwd -d usernameyoulike 
 +# add the user to the sudoers list 
 +usermod -aG sudo usernameyoulike 
 +</code>
  
 ===== udev ===== ===== udev =====
  
-I fell in a deep rabbit hole with udev whilst building Primo. Here is a +I fell in a deep rabbit hole with ''%%udev%%'' whilst building Primo. Here is a 
-[[http://www.reactivated.net/writing_udev_rules.html|comprehensive guide about +comprehensive guide about ''%%udev%%'' [[http://www.reactivated.net/writing_udev_rules.html|link]].
-this]].+
  
-To get all the information about a usb device: +To get all the information about a USB device: 
  
 <code bash> <code bash>
Line 18: Line 30:
 Some commands have changed since the bible has been written. Some commands have changed since the bible has been written.
  
-To test, you can use the test function of udevadm. Problem is that you have to give +To test, you can use the test function of ''%%udevadm%%''. Problem is that you have to give 
-it the top level device path in sysfs. For example, an arduino plugged into +it the top level device path in ''%%sysfs%%''. For example, an arduino plugged into 
-Primo and showing up as ttyACM1, this was /sys/bus/usb/devices/1-6. To find the +Primo and showing up as ''%%ttyACM1%%'', this was 
-top level device path, use the command above and susbitute in the port name.+''%%/sys/bus/usb/devices/1-6%%''. To find the top level device path, use the 
 +command above and substitute in the port name.
  
-To test an arduino:+To test an Arduino:
 <code bash> <code bash>
 udevadm test /sys/bus/usb/devices/1-6 udevadm test /sys/bus/usb/devices/1-6
 </code> </code>
  
-To restart the udev system:+To restart the ''%%udev%%'' system:
 <code bash> <code bash>
 sudo udevadm control --reload-rules && udevadm trigger sudo udevadm control --reload-rules && udevadm trigger
Line 35: Line 48:
 You will still need to unplug/replug stuff!! Or do a reboot.  You will still need to unplug/replug stuff!! Or do a reboot. 
  
-Some pittfalls I came accross. You cannot change device names! You can only add +Some pitfalls I came across. You cannot change device names! You can only add 
-symlinks to them. The symlink did not work for the tara uvc_camera. I think this is +symlinks to them. The symlink did not work for the Tara uvc_camera. I think this is 
-issue has to do with the fact that the tara has some weird shit with the way the+issue has to do with the fact that the Tara has some weird shit with the way the
 USB host onboard handles the two cameras. USB host onboard handles the two cameras.
 +
 +Here's some other commands:
 +
 +Lists the possible device attribute keys and their values along with the
 +parents of the device.
 +
 +<code bash>
 +udevadm info --attribute-walk /dev/bus/usb/<bus_num>/<device_num>
 +</code>
 +
 +Lists the device attributes and their values.
 +<code bash>
 +udevadm info -a /dev/video0
 +</code>
 +
 +Reload udev rules
 +<code bash>
 +udevadm control --reload-rules && udevadm trigger
 +</code>
  
 ==== USB Information ==== ==== USB Information ====
  
-To get info on hidraw devices:+To get info on ''%%hidraw%%'' devices:
  
 <code bash> <code bash>
Line 59: Line 91:
 </code> </code>
  
-When doing lsusb, use sudo!! If you don't, you won't be able to see devices whose+When doing ''%%lsusb%%'', use ''%%sudo%%''!! If you don't, you won't be able to see devices whose
 permissions haven't been properly set. permissions haven't been properly set.
 +
 +Shows the USB version of the devices with that vendor id:
 +<code bash>
 +sudo lsusb -v | grep 2560 -A 10 | grep bcdUSB
 +</code>
  
 ===== cron ===== ===== cron =====
Line 109: Line 146:
 ==== Terminal ==== ==== Terminal ====
  
-I use the xfce4-terminal. I have all nicely setup with a config file that resides in ~/.config/xfce4/terminal +I use the ''%%xfce4-terminal%%''. I have all nicely setup with a config file 
 +that resides in ''%%~/.config/xfce4/terminal%%''.
  
 ===== Moving Windows ===== ===== Moving Windows =====
Line 153: Line 191:
 xubuntu (xfce) desktop. xubuntu (xfce) desktop.
  
-using the x11 VNC server on the server. Port 5900 and 5901+using the x11 VNC server on the server. Port 5900 and 5901.
  
 Running into security issues with the VNC server stuff. Tried: Running into security issues with the VNC server stuff. Tried:
Line 185: Line 223:
  
 Problem is that it is slow. I don't think there is anything we can do it. It is also Problem is that it is slow. I don't think there is anything we can do it. It is also
-slow through the lan. I've attributed this issue to running headless.+slow through the LAN. I've attributed this issue to running headless.
  
 ===== Headless Operation ===== ===== Headless Operation =====
Line 239: Line 277:
   * use ssh -X if you want to ssh with an X server   * use ssh -X if you want to ssh with an X server
  
-To remove all files except for one in zsh:+To remove all files except for one in ''%%zsh%%'':
  
 <code bash> <code bash>
Line 245: Line 283:
 rm -- ^file.txt rm -- ^file.txt
 </code> </code>
 +
 ==== Clipboard ===== ==== Clipboard =====
  
Line 251: Line 290:
 sudo apt install xclip sudo apt install xclip
 cat file | xclip -selection clipboard cat file | xclip -selection clipboard
 +</code>
 +
 +
 +====== Window File Subsystem for Linux ======
 +
 +This thing is awesome! 
 +
 +For setting up ssh keys, xclip doesn't work. Use the following:
 +<code bash>
 +clip.exe < ~/.ssh/id_rsa.pub
 +</code>
 +
 +===== SSH Access =====
 +
 +For setting up external ssh access I did the following:
 +
 +Reinstall openssh for some reason:
 +<code bash>
 +sudo apt-get purge openssh-server
 +sudo apt-get install openssh-server
 +</code>
 +
 +From an elevated powershell I ran this to change the port to 2222 to not
 +interfere with any windows services:
 +<code bash>
 +New-NetFirewallRule -DisplayName "Allow Inbound Port 2222" -Direction Inbound -LocalPort 2222 -Protocol TCP -Action Allow
 +</code>
 +
 +I added the following to sshd_config:
 +
 +<code bash>
 +Port 2222
 +PermitRootLogin no
 +AllowUsers paul
 +</code>
 +
 +I created an authorized hosts file and imported the keys.
 +
 +I tested the connection by running this on the server:
 +<code bash>
 +sudo service ssh stop
 +sudo /usr/sbin/sshd -d
 +</code>
 +
 +Then on the client I ran a debug version of an ssh server to see if I was
 +receiving incoming connections.
 +<code bash>
 +ssh name@server -p 2222
 +</code>
 +
 +I then monitored the server and make sure I could see the connection. The debug
 +client quit out cause it didn't have correct paths to the keys, but the test was
 +a success cause it validated the port pass through. I then restarted the regular
 +service like this:
 +
 +<code bash>
 +sudo service ssh start
 </code> </code>
  
  • linux.1551126314.txt.gz
  • Last modified: 2019/02/25 20:25
  • by paul