# Connect to a Wireless Router
# $1 = interface (use ip link)
#!/bin/bash
# Enable the interface
ip link set $1 up
# Find access point names
iw dev $1 scan | grep SSID
# Select SSID and enter password
printf "SSID: "
read SSID
printf "pass: "
read -s PASS
# Connect
TEMPFILE=`mktemp`
wpa_passphrase $SSID $PASS > $TEMPFILE
wpa_supplicant -i $1 -c $TEMPFILE -B
rm $TEMPFILE
dhcpcd $1
Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts
Tuesday, July 18, 2017
Wednesday, May 17, 2017
RTAGS Quick Setup
RTAGS is a tool for C/C++ code navigation and completion (primarily for Emacs). Here's how to get it working quickly on Arch:
(require 'rtags)
(require 'company-rtags)
(setq rtags-completions-enabled t)
(eval-after-load 'company
'(add-to-list
'company-backends 'company-rtags))
(setq rtags-autostart-diagnostics t)
(rtags-enable-standard-keybindings)
(define-key c-mode-base-map (kbd "M-.") 'rtags-find-symbol-at-point)
(define-key c-mode-base-map (kbd "M-,") 'rtags-location-stack-back)
You may want to enable automatic starting of rdm:;; autostart rdm when entering c modes
(add-hook 'c-mode-hook 'rtags-start-process-unless-running)
(add-hook 'c++-mode-hook 'rtags-start-process-unless-running)
See also:
https://github.com/Andersbakken/rtags
http://syamajala.github.io/c-ide.html
- Get the tool: git clone https://aur.archlinux.org/packages/rtags-git/ ; cd rtags-git/ ; makepkg -si
- Alternatively run `rtags-install` within emacs.
- Start the server: rdm &
- Index your project: cd project-code-dir/ ; make -nk | rc -c -
(require 'rtags)
(require 'company-rtags)
(setq rtags-completions-enabled t)
(eval-after-load 'company
'(add-to-list
'company-backends 'company-rtags))
(setq rtags-autostart-diagnostics t)
(rtags-enable-standard-keybindings)
(define-key c-mode-base-map (kbd "M-.") 'rtags-find-symbol-at-point)
(define-key c-mode-base-map (kbd "M-,") 'rtags-location-stack-back)
You may want to enable automatic starting of rdm:;; autostart rdm when entering c modes
(add-hook 'c-mode-hook 'rtags-start-process-unless-running)
(add-hook 'c++-mode-hook 'rtags-start-process-unless-running)
See also:
https://github.com/Andersbakken/rtags
http://syamajala.github.io/c-ide.html
Saturday, March 18, 2017
Arch installation checklist (i3 desktop)
During basic setup remember to install base-devel as well as base. After basic setup and first reboot:
- Check network (ping 8.8.8.8). If down, find adapter name using ip link and enable dhcp using systemctl enable dhcpcd@<adapter name>.service
- Add a user: useradd -m -G groupname -s /bin/bash username. Enable sudo for that user by editing /etc/sudoers.
- Install:
xorg-server xorg-apps xorg-xinit [graphics-driver] #xorg stuff
i3 dmenu lxappearance compton # Desktop environment
terminator/urxvt firefox git emacs feh bash-completion #Apps
dialog wpa_supplicant wpa_actiond #wireless - Setup xorg to autostart i3. Add exec i3 to ~/.xinitrc (cp /etc/X11/xinit/xinitrc ~/.xinitrc).
- Setup dot-files for i3, i3status, bash (+aliases), emacs and more (via dotfile repo).
- Update X fonts by running lxappearance.
- Setup AUR applications (e.g. Dropbox)
- For wireless, generate configurations by running wifi-menu and enable automatic connection management: sudo systemctl enablenetctl-auto@<interface>.service where interface is the name the wireless card (use ip link to see it) .
Tuesday, June 24, 2014
Makefile template
A makefile to be used as template. It automatically creates header dependencies using the -MMD flag of gcc so the user only needs to specify the source files. Libraries and compiler flags are generated using pkg-config.
CXXFLAGS = -g -I/usr/include/blah $(shell pkg-config --cflags thelib)
LIBS = $(shell pkg-config --libs thelib) -lotherlib
CXX = g++
SOURCES = source.cpp
OBJS = $(SOURCES:.cpp=.o)
DEPS = $(SOURCES:.cpp=.d)
TARGET = a.out
$(TARGET): $(OBJS)
$(CXX) -o $(TARGET) $(OBJS) $(LIBS)
all: $(TARGET)
%.o: %.cpp
$(CXX) $(CXXFLAGS) -MMD -MP -c $< -o $@
clean:
rm -f $(OBJS) $(TARGET) $(DEPS)
-include $(DEPS)
CXXFLAGS = -g -I/usr/include/blah $(shell pkg-config --cflags thelib)
LIBS = $(shell pkg-config --libs thelib) -lotherlib
CXX = g++
SOURCES = source.cpp
OBJS = $(SOURCES:.cpp=.o)
DEPS = $(SOURCES:.cpp=.d)
TARGET = a.out
$(TARGET): $(OBJS)
$(CXX) -o $(TARGET) $(OBJS) $(LIBS)
all: $(TARGET)
%.o: %.cpp
$(CXX) $(CXXFLAGS) -MMD -MP -c $< -o $@
clean:
rm -f $(OBJS) $(TARGET) $(DEPS)
-include $(DEPS)
Friday, September 20, 2013
Setup static ip on Ubuntu Server
Edit /etc/network/interfaces
Change iface eth0 inet dhcp to
iface eth0 inet static
address 192.168.1.200
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
dns-nameservers 8.8.8.8 8.8.4.4
Since most other systems on your network will use dhcp, pick an address that doesn't cause conflict. Most routers will assign small numbers 1st (192.168.1.[1,2,3..]) so pick a big one. Obviously, the rest of the settings need to be change to match your network.
Change iface eth0 inet dhcp to
iface eth0 inet static
address 192.168.1.200
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
dns-nameservers 8.8.8.8 8.8.4.4
Since most other systems on your network will use dhcp, pick an address that doesn't cause conflict. Most routers will assign small numbers 1st (192.168.1.[1,2,3..]) so pick a big one. Obviously, the rest of the settings need to be change to match your network.
Labels:
Linux
Thursday, September 19, 2013
Setting up a home file server
1. Download Ubuntu Server and copy to a usb stick using UNetbootin.
2. Boot your server from the usb stick.
3. The installation is pretty much straightforward. Just select "guided partitioning" and the disk/partition that you want to install to and the installer will do the rest.
4. When prompted for packages to install, select ssh-server and samba.
5. After booting into the new system we need to setup a few things.The 1st is to set up a static IP so that you can connect to the server from elsewhere using ssh.
6. Next we need to setup samba so that we can share our files.
$ nano /etc/samba/smb.conf
Here we can change the workgroup name to match the workgroup name on the machines that will be connecting to the server (WORKGROUP is the Windows 7 default). We also need to specify the folders on the server that will be shared on the network. We do this by adding the following entry at the end of smb.conf:
[public]
comment = Just a comment
path = /path/to/share/point
read only = no
guest only = yes
guest ok = yes
Add one entry per share point and change the path accordingly.
7. Additionally we can install transmission so that our file server can grab torrents.
2. Boot your server from the usb stick.
3. The installation is pretty much straightforward. Just select "guided partitioning" and the disk/partition that you want to install to and the installer will do the rest.
4. When prompted for packages to install, select ssh-server and samba.
5. After booting into the new system we need to setup a few things.The 1st is to set up a static IP so that you can connect to the server from elsewhere using ssh.
6. Next we need to setup samba so that we can share our files.
$ nano /etc/samba/smb.conf
Here we can change the workgroup name to match the workgroup name on the machines that will be connecting to the server (WORKGROUP is the Windows 7 default). We also need to specify the folders on the server that will be shared on the network. We do this by adding the following entry at the end of smb.conf:
[public]
comment = Just a comment
path = /path/to/share/point
read only = no
guest only = yes
guest ok = yes
Add one entry per share point and change the path accordingly.
7. Additionally we can install transmission so that our file server can grab torrents.
Labels:
Linux
Thursday, May 9, 2013
Keep command running after logging out
Use nohup to keep a command running after you exit the shell. Useful for running stuff on remote machines without having to be logged in.
- Login to a machine
- nohup command &
- Logout, command keeps running
Labels:
Linux
Thursday, April 11, 2013
Pipe to clipboard
Copy the output of a command into clipboard:
echo adafasdfa | xclip
Useful for pasting command line output into text editors, spreadsheets etc.
xclip -o | grep name
Useful for pasting large selections (etc from a browser). Equivalent to middle clicking the terminal (but less messy).
Labels:
Linux
Wednesday, April 10, 2013
Compile using pkg-config
pkg-config makes it easier to compile your source when you need to link libraries. For example, building a Qt application that has OpenGL support requires the following build command:
g++ source.cpp -DQT_SHARED -I/usr/include/qt4 -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtOpenGL -I/usr/include/qt4/QtGui -lQtOpenGL -lQtGui -lQtCore
With pkg-config that becomes:
g++ source.cpp `pkg-config --libs --cflags QtCore QtOpenGL `
Note the use of back-quotes `` to do in-line substitution.
pkg-config can be integrated into eclipse through a pluggin and is also supported by qmake. Just add the following to your .pro file:
CONFIG += link_pkgconfig
PKGCONFIG += name_of_library
Labels:
Linux
Monday, April 8, 2013
Mounting remote folders using ssh and SAMBA
Two ways to mount your remote folders. Use sshfs over unreliable network. Get uid, gid by running id on linux.
mount -t cifs //samba_server/folder ~/yoho/ -o user=username,domain=COMPANY,uid=xxxx'
This will mount remote /folder to local folder ~/yoho.
sshfs -o workaround=rename -o reconnect -o idmap=user -o uid=xxxx -o gid=xxxx -o allow_other username@computer_with_ssh_access.company.com: ~/yuhu/
This will mount the home folder of user username at local folder ~/yuhu.
Labels:
Linux
Subscribe to:
Posts (Atom)