Showing posts with label fedora. Show all posts
Showing posts with label fedora. Show all posts

Friday, August 8, 2014

Change Directory and list contents in single command.

I find myself often changing to a directory and immediately performing an `ls`. This is partly habit and partly the fluid nature nature of the files I work on.  Anyway, you don't care about that...

Using an editor of your choosing open your .bashrc or .bash_profile and add the following lines:
# User defined functions
function cdl { cd $1 && echo $PWD && ll; }
Note: In the above I have aliased `ll` as ->  alias ll='ls -ASlh'
Note: You can name this whatever you choose, I just think `cdl` made sense.
Note: You can omit the echo $PWD if you don't care to see the directory path in the output. So you could do something as simple as:
# User defined functions
function cdl { cd $1 && ls; }
Save and close and then
bkarels@rev0:~$ source ~/.bashrc
Now you can use cdl (or whatever you've named it to change directory and immediately ls the contents.

Example:
bkarels@rev0:~$ cdl foo/
/home/bkarels/foo
total 328K
-rw-------   1 bkarels bkarels 156K Aug  8 09:39 sample0
-rw-------   1 bkarels bkarels 6.9K Aug  8 08:47 someFile27
-rw-r--r--   1 bkarels bkarels 4.1K Aug  7 12:07 sayWhat
drwx------   6 bkarels bkarels 4.0K Aug  8 07:37 killWindows.exe
The above example was done on Debian 7 (Wheezy) but should work on all flavors of *nix and OSX.

FIN

Tuesday, April 1, 2014

Quick & Dirty Add User to SUDOERs (*nix)

While there is near endless and very powerful ways to configure user permissions, you've just spun up a virtual machine using VMWare or Virtual Box and you want God permissions for your user so you're not always becoming root (and then forgetting that you're root). The following example is from CentOS 6.5. Since you can destroy a system if you muck up the sudoers file just using any old text editor is not recommended. Hence, we shall use visudo.

[myuser@machine ~]$ su -
Password:
[root@machine ~]# visudo

This will open your sudoers file for editing. visudo will protect you from some, but not nearly all mistakes. So, for this quick dirty example search for the following section:
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
Then, add the following directly below it:
myuser ALL=(ALL) ALL
The end result should look like:
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
myuser ALL=(ALL) ALL
NOTE: The above is separated by TABS so you would type it as follows:
myuser[TAB]ALL=(ALL)[TAB]ALL

Save & close (:wq) 

[root@machine ~]# exit
[myuser@machine ~]$ sudo someCommand

FIN

Wednesday, March 5, 2014

Connect to SMB share with terminal - Fedora20

The non-gui way to connect to your SMB share. There is likely 1000 small variations of how to do this, but this is a very simple method to get you on to the path to bigger, better, cooler...

From a terminal:
[user@localhost user] $ cd /mnt
[user@localhost mnt] $ sudo mkdir shareExample
[user@localhost mnt] $ sudo mount -o username=user //theShareLocation/shareName /mnt/shareExample/
You will likely be prompted for your passwd...
[user@localhost mnt] $ cd /mnt/shareExample
[user@localhost shareExample] $ look around, do stuff...

NOTE: If you're accessing a SMB share on windows you will like need to connect using:
[user@localhost mnt]$ sudo mount -t smbfs -o username=username //theShareLocation/shareName /mnt/shareExample/

...and when you're done:
[user@localhost mnt]$ sudo umount /mnt/shareExample

This should work on all flavors of *nix, done here on Fedora20 as that is what I'm using at the moment.

FIN