One Of The Most Important Tools In Linux – Understanding Chmod

By Danny Stieben, MakeUseOfApril 27, 2013 at 02:31PM

linux chmodThere are plenty of features that make Linux special, but one of them that makes it so secure is its permissions system. You can have fine-grain control over all the files in your system and assign permissions to users, groups, and everyone else. The terminal utility “chmod” helps you control all the permissions on your system, so it’s vital to know how chmod works in order to get the most use out of this feature, especially if you’re planning on building your own Linux server.

There’s plenty of information that you’ll need to know in order to understand the mechanics of the permissions system and control it as you please, so get ready to take some notes. Additionally, for starters, it’s best to take a look at 40 terminal commands that you should be familiar with before diving in.

Components Of Permissions

The Linux permissions system is configured in such a way that you can assign file and directory permissions to three different categories – the user, the group, and everyone else. Each file or directory is owned by a user and group, and these fields cannot be empty. If only the user should own the file, then the group name is often the same as the username of the owner.

You can assign specific permissions to the owner, different permissions to the group, and even other permissions to every other user. The different permissions which you can assign to any of these three categories are:

  • read – 4 – ‘r’
  • write – 2 – ‘w’
  • execute – 1 – ‘x’

The numbers 4, 2, and 1 as well as the letters r, w, and x are different ways in which you can assign permissions to a category. I’ll get to why these numbers and letters important later on.

Permissions are important because, as you might assume, they allow certain people to do certain things with the file. Read permissions allow the person or group to read the contents of the file, and copy it if they wish. Write permissions allows the person or group to write new information into the file, or overwrite it completely. In some cases this can also control who is allowed to delete the file; otherwise a sticky bit must be used that won’t be covered here. Finally, execute permissions allow the person or group to run the file as an executable, whether it’s a binary file, an .sh file, or anything else.

Understanding Assigned Permissions

linux chmod

Let’s go in your terminal to any folder on your system – say your Home folder. Go ahead and type in the command ls -l and hit enter. This command lists out all of the files and directories found in whatever folder you’re currently in.

Each line represents a file or directory, and it begins with something that might look like -rw-rw-r–. This shows you the permissions of the file or directory. In this case, the first dash shows us that you’re looking at a file. If it were a directory, there would be a “d” in this spot. The next three spots, rw-, shows us that the user who owns the file has read and write permissions (rw), but no executable permissions as there’s a dash instead of an “x”. The same is repeated for the next three spots, which represents the permissions of the group that owns the file.

Finally, the last three spots are r–, which means that everybody else can only read the file. As a reference, the possible permissions are drwxrwxrwx. It’s also important to note the “dmaxel dmaxel” that you see after the permissions. This shows that the user owner of the file is dmaxel and the group owner is dmaxel. For files that really are only supposed to belong to one user, this is default behavior, but if you’re sharing with a group that has multiple members, then you’ll be able to see that.

Assigning New Permissions

linux chmod

Remember the numbers and letters I mentioned earlier? Here’s where you’ll need them. Let’s say you have a file called “important_stuff” that’s located at the path /shared/Team1/important_stuff. As the team leader, you’ll want to be able to read and write to the file, your group members should only be allowed to read the file, and everyone else shouldn’t have any permissions at all.

In order to make sure that you and your group own the file, you’ll need to run the command chown. An appropriate command for this situation would be chown me:Team1 /shared/Team1/important_stuff. That command runs chown, and tells it that the file at path /shared/Team1/important_stuff should belong to the user “me” and the group “Team1″.

It’s assumed that the desired group has been created and that members have the group added as a secondary group in the system (also not covered here). Now that you have set the owner and group, you can set the permissions. Here, you can use the command chmod 640 /shared/Team1/important_stuff. This starts chmod, and assigns the permissions 640 to the file at path /shared/Team1/important_stuff.

Where did 640 come from? You look at the numbers represented by the different commands – for read and write permissions, you have 4 + 2 = 6. The 6 represents the permissions for the user. The 4 comes from just the read permissions for the group, and the 0 comes from no permissions for everyone else. Therefore, you have 640. The number system is very good because you can have a number for all possible combinations: none (0), x (1), w (2), r (4), rx (5), rw (6), and rwx (7).

As an example, full permissions for everyone would be 777. However, if you have security in mind, its best to assign only the permissions that you absolutely need – 777 should be used rarely, if at all.

Alternative Method

While I prefer the number method of assigning permissions, you can increase your flexibility and also add or remove permissions using the representative letters. For the above situation, the command used could also be chmod u=rw,g=r,o= /shared/Team1/important_stuff. Here, u=rw assigns read and write permissions to the user, g=r assigns read permissions to the group, and o= assigns no permissions to everyone else. There’s also ‘a’ which can assign the same permissions for all categories.

You can also combine different combinations for varying permissions, as well as + or – signs instead of =, which would simply add or remove permissions if they haven’t already been added/removed instead of completely overwriting the permissions that you’re changing.

So, different examples can include:

  • chmod a+x /shared/Team1/important_stuff assigns execute permissions to everyone if they don’t have it already
  • chmod ug=rw o-w /shared/Team1/important_stuff forces the user and group to just have read and write permissions, and takes away writing permissions for everyone else in case they had it.

Applying Permissions To Multiple Files

Additionally, you can add the -R flag to the command in order to recursively apply the same permissions to multiple files and directories within a directory. If you wanted to change the permissions of the Team1 folder and all files and folders within, you can run the command chmod 640 -R /shared/Team1.

Applying the same permissions to multiple, but individually picked files can be done with a command such as chmod 640 /shared/Team1/important_stuff /shared/Team1/presentation.odp.

Conclusion

Hopefully, these tips have helped you improve your knowledge of the permissions system found in Linux. Security is an important matter to consider, especially on mission-critical machines, and using chmod is one of the best ways to keep security tight. While this is a fairly in-depth look at using chmod, there’s still a bit more that you can do with it, and there are plenty of other utilities that complement chmod. If you need a place to start, I would suggest doing more research on all of the things you can do with chown.

If you’re just getting started with Linux, have a look at our Getting Started Guide to Linux.

Are file permissions important for you? What permissions tips do you have for others? Let us know in the comments!

Image Credit: Eduardo Amorim

The post One Of The Most Important Tools In Linux – Understanding Chmod appeared first on MakeUseOf.

MySQL Triggers with Logging

By Michael McLaughlin, Planet MySQLApril 26, 2013 at 01:01AM

Somebody asked why you can’t implement MySQL triggers that write information when you want to stop the DML statement, like autonomous procedures in Oracle. The question was a surprise but I didn’t find anything on it, so here’s how you can do it. This is more or less like an autonomous process by leveraging both the InnoDB and MyISAM engine’s behaviors. This post leverages an earlier explanation of MySQL Triggers.

  1. First you create a MyISAM table, which is a persistent store that auto commits when you’re other InnoDB tables can be transactionally dependent. Here’s a simple MyISAM logger table.
CREATE TABLE logger
( logger_id         INT UNSIGNED AUTO_INCREMENT PRIMARY KEY
, logger_event      VARCHAR(50)
, logger_table      VARCHAR(50)
, logger_instring   VARCHAR(100)
, logger_outstring  VARCHAR(100)
, created_by        INT UNSIGNED
, creation_date     DATE
, last_updated_by   INT UNSIGNED
, last_update_date  DATE) ENGINE=MyISAM;
  1. Next, you create an on-insert trigger that changes an input but doesn’t stop the transaction. It also writes to the logger MyISAM table in the scope of the transaction.
CREATE TRIGGER contact_insert
BEFORE INSERT ON contact
FOR EACH ROW
BEGIN
 
  /* Check if last name contains a white space. */
  IF new.last_name REGEXP '^.* .*$' THEN
 
    /* Insert into an MyISAM table, which auto commits in the scope
       of a transaction. */
    INSERT INTO logger
    VALUES ( null
           ,'insert'
           ,'contact'
           , new.last_name
           , REPLACE(new.last_name,' ','-')
           , new.created_by
           , new.creation_date
           , new.last_updated_by
           , new.last_update_date );
 
    /* Replace the name for the INSERT INTO the CONTACT table. */
    SET new.last_name := REPLACE(new.last_name,' ','-');
  END IF;
END;
$$
  1. Next, you create an on-update trigger that changes an update while aborting the transaction. It also writes to the logger MyISAM table because its outside the InnoDB scope of a transaction and auto committed on insert.
CREATE TRIGGER contact_update
BEFORE UPDATE ON contact
FOR EACH ROW
BEGIN
 
  /* Check if last name contains a white space. */
  IF new.last_name REGEXP '^.* .*$' THEN
 
    /* Insert into an MyISAM table, which auto commits in the scope
       of a transaction. */
    INSERT INTO logger
    VALUES ( null
           ,'update'
           ,'contact'
           , new.last_name
           , null           
           , old.created_by
           , old.creation_date
           , new.last_updated_by
           , new.last_update_date );
 
    /* Throw an exception to force the business user to see they
       can't update a last name with a white space. */
    SIGNAL SQLSTATE '42000';
  END IF;
END;
$$
  1. Next, you create a test case with an INSERT and UPDATE statement that meets the condition of the triggers.
/* Insert a row meeting the trigger condition. */
INSERT INTO contact VALUES
( null, 1001, 1003,'Catherine', null,'Zeta Jones', 1001, UTC_DATE(), 1001, UTC_DATE());
 
/* Update a row meeting the trigger condition. */
UPDATE contact
SET    last_name = 'Zeta Jones'
,      last_updated_by = 1003
,      last_update_date = UTC_DATE()
WHERE  last_name = 'Zeta-Jones';
  1. Last, query the logger table. You have a record inserted for both the allowed behavior and the aborted behavior. This means you have the ability to capture material that should never be inserted or updated into a table and who did it by leveraging the who-audit columns of the table.
SELECT * FROM logger;

It returns:

+-----------+--------------+--------------+-----------------+------------------+------------+---------------+-----------------+------------------+
| logger_id | logger_event | logger_table | logger_instring | logger_outstring | created_by | creation_date | last_updated_by | last_update_date |
+-----------+--------------+--------------+-----------------+------------------+------------+---------------+-----------------+------------------+
|         1 | insert       | contact      | Zeta Jones      | Zeta-Jones       |       1001 | 2013-04-26    |            1001 | 2013-04-26       |
|         2 | update       | contact      | Zeta Jones      | NULL             |       1001 | 2013-04-26    |            1003 | 2013-04-26       |
+-----------+--------------+--------------+-----------------+------------------+------------+---------------+-----------------+------------------+
2 rows in set (0.00 sec)

This effectively delivers in MySQL the equivalent of an autonomous transaction in Oracle. The result from the non-critical trigger records the before and after value, while the results from the critical update trigger only record the before values because the event is aborted by raising an error in the trigger. As always, I hope this helps somebody looking for a solution.

PlanetMySQL Voting:
Vote UP /
Vote DOWN

10 Productivity Apps For Your Mac-Based Home Office

By Bakari Chavanu, MakeUseOfApril 26, 2013 at 08:31PM

If you work at homebased office like I do, you no doubt spend a significant amount of time getting things done on your Mac. While I have already written about the advantages of using a standup desk, there are also several important and general productivity apps for almost any type of workflow you engage in.

Though there is no robot application (yet!) that can do all the work for me, the following are 10 of the most useful free or low-cost productivity apps that I use on a daily or regular basis. These applications not only save me time but in many cases help me work more efficiently.

Fantastical

It’s difficult to work in any home-based office and not need a useful calendar. Though OS X comes installed with a default Calendar application, the third-party option, Fantastical ($19.99) is hands down the best calendar you should run on your Mac.

With Fantastical, you can input and check calendar events and schedules right from your Mac’s menu bar. You can create a new event simply by opening Fantastical’s drop-down window and entering the data for the event. Instead of clicking numbers and times, you simply write the event as if you were writing it on a scratch sheet of paper.

For example, to schedule a lunch meeting for next Wednesday, simply type: “Lunch with Bakari next wed, 11:30am, at Fresh Choice.” As you type, you watch Fantastical fill in all the data for you.

Fantasical app

You can preset the type of reminders you want for calendar events. Fantastical syncs with Apple’s Calendar application, but there’s also an iPhone version ($8.99) of Fantastical that works the same way. By having Fantastical in your menu bar, you don’t have to open the Calendar app just to add or review a few events.

Super Memory Cleaner

If you find that your Mac slows down throughout the day or when you have several applications open, you should download Super Memory Cleaner (free). It does a great job of cleaning up hundreds of megabytes, or even gigabytes, of memory with one simple click. You can select to have it auto-clean, or clean at startup.

Super Memory Cleaner

Desktop Wallpapers

If you meet clients in your home office, and/or you like your office to have professional décor, your desktop wallpaper should be just as classy as your iMac or Macbook computer. My wallpaper of choice is a collection produced by Vlad Studio.

Vlad Studio

These free wallpapers are designed by digital artist, Vlad Gerasimov, and you can download them for nearly any size desktop monitor. I recommend selecting and downloading a few dozens of your favorites and simply have your Mac change the pictures everyday, or each time you wake up your Mac. I find that these unique wallpapers add a little inspiration to my daily workflow.

Caffeine

There are occasions when you need to keep your Mac desktop or laptop awake when you’re doing a presentation, or playing a video while multitasking in another part of your office. This is where Caffeine (free) comes in. When you enable it, it keeps your Mac from going to sleep until you cut if off. Jackson reviewed this application when it was first released back in 2008.

Caffeine

Wunderlist

There are no shortage of to-do applications for the Mac, but if you’re still looking for one, you should give Wunderlist (free) a try. Dave reviewed the iOS mobile version of Wunderlist, but the desktop version contains a similar user interface.

Wunderlist

Wunderlist is a clean, well designed cross-platform program where you can mange and sync all of your to-do lists. You can also share and collaborate lists with your colleagues. If you don’t need a task manager with lots of bells and whistles, Wunderlist can be very useful in your workflow.

FunctionFlip

FunctionFlip (free/donation) is a Preferences utility that allows you to customize those Fn keys at the top of your keyboard that you might rarely use. For instance, while I constantly use the assigned volume keys, I hardly ever use the brightness, iTunes, Exposé and Launchpad Fn keys on my iMac.

So with FunctionFlip, I can turn off those functions and assign them another purpose using applications like Keyboard Maestro or QuickSilver.

FunctionFlip

Trello

Another useful task and project manager is an online and mobile application called Trello. It’s sort of like a whiteboard for sorting ideas, lists of tasks, and project workflows. You can share your “whiteboards” with others, and view them in any web browser or the iOS version (free) of of the application and service. Erez reviewed Trello in more detail here.

Trello5

Launchpad Manager

If you have amassed a lot of applications on your Mac, you have probably experienced how difficult it is to use Launchpad to access all of your applications. The Launchpad feature in Lion and Mountain Lion is not very useful if you don’t have your applications organized alphabetically or in folders. This is where Launchpad Manager ($7.99) comes in.

Launchpadmanager

Launchpad Manager includes over a dozen features, including the ability to alphabetize applications, delete icons from Launchpad without uninstalling the applications themselves, and move selected applications to another Launchpad page. You can easily move applications into groups, rename icons and groups, and quickly cut and paste applications from one folder to another. You can use custom layouts of your Launchpad for different purposes.

You can download a free version of Launchpad Manager, but many of its advanced features are only available in the paid pro version.

Dropzone

Dropzone ($9.99) is a nifty little application that enables you to perform various tasks from the menu bar or from the left or right side of your desktop screen. For example, say you download a new application that is delivered to you in a DMG file. You can drag that DMG file to Dropzone and drop it on the Install Application action, and it will proceed to automatically open and install that application, and then delete the DMG file for you.

Dropzone

You can create another action that sends files to a pre-selected folder. There’s actions for quickly printing a file or converting a long URL to a bit.ly short URL. You can download a 15-day trial of the application, which I recommend. Spend some time with it, and check out the user contributed actions for Dropzone.

If you find more than five actions that will enable you to be more productive, then it may be worth paying for the application, which you should download from the Mac App Store.

Time Out

One of the ways to be more productive in your Mac-based home office is to actually take breaks from your Mac. Time Out (free) will remind you to take “normal”, say 10 minute breaks, and “micro” breaks, like 10 seconds every 30 minutes, based on the time intervals you set.

Overview

When I don’t use this application, I end up working at my computer for hours before I take a break. Not taking a break causes a strain on my eyes, and by the afternoon I’m less productive. You can postpone or skip breaks, but doing so too often will defeat the purpose.

That’s it for my Mac-based home office applications. Let us know which applications you find most useful in your workflow.

The post 10 Productivity Apps For Your Mac-Based Home Office appeared first on MakeUseOf.

The Right Way to Care for Your Pocket Knife

By Alan Henry, LifehackerApril 26, 2013 at 08:00AM

You may know how to care for a kitchen knife, but when’s the last time you paid your simple pocket knife the attention it deserves? Instructables user kennethisme has a great tutorial on how to care for your average folding pocket knife, from cleaning the blade to lubricating the body.

It’s something that a lot of people overlook, especially if your primary use for a pocket knife is opening packages, mail, and occasionally cutting zip ties and other tough plastic bits. Just like a kitchen knife, the dirtier it gets the more dangerous it is, so keeping it in good condition is important. Kennethisme scrubs the blade down with warm, soapy water and an old toothbrush, and then moves on to picking the right lubricant to keep the hinge, lock, and other moving parts well oiled. He suggests a petroleum-based wet lubricant, as opposed to a spray-on dry lubricant that will attract lint or dust. Similarly, he points out that you should use a food-grade lubricant if you plan to use your pocket knife in any food preparation.

Hit the link below for the whole guide and a few more tips, including specific lubricant suggestions. He doesn’t get into keeping a pocket knife sharp, but the principles there are similar to other, previously mentioned kitchen skills. Unfortunately taking proper care of a pocket knife is something many of us often forget, and the guide makes it easy.

Pocket Knife Maintenance: Cleaning and Lubricating | Instructables

Force Windows to Use Your Wired Connection Instead of Wi-Fi

By Melanie Pinola, LifehackerApril 26, 2013 at 01:30PM

If you have a wireless connection and then plug into your wired network, Windows might continue to use your wireless connection for your network usage. Here’s how to change it so Windows uses your wired connection by default.

As explained on Microsoft, when more than one network connection is available, Windows will choose the one with the lowest metric value (automatically assigned based on the network connection’s rated speed). Previously, to change the default priority of each interface you would change the metric value for each connection. NirmalTV suggests a newer, simpler method:

  • Go to Network Connections under the Control Panel
  • Under the file menu, go to Advanced > Advanced Settings
  • In the Adapters and Bindings tab, click on the connection you want prioritized (e.g., the ethernet connection) and use the up arrow to move it to the top of the list

That’s it! Hit OK and now your wired connection will be the default (when you’re plugged in, that is).

How to Make Windows Select Wired Connection Instead of Wireless Connection | NirmalTV

Pull Dents Out of Your Car with a Hot Glue Gun

By Eric Ravenscraft, LifehackerApril 25, 2013 at 03:00PM

You may be able to pull out small dents in your car using a hot glue gun and some wooden dowels with a DIY version of what’s known as a “glue pull.”

In professional shops, a glue pull involves attaching handles to a dent with hot glue and then tugging them out with specialized tools (as demonstrated in this video). For small dents, however, YouTube user Tom demonstrates how you can perform a similar technique at home with a hot glue gun and some makeshift handles.

This method requires a bit of finesse, some trial and error, and may not be for everyone. Glue shouldn’t harm your paint job, but when you’re dealing with bending metal, fixes can get very subjective. We haven’t seen too many DIY videos for this technique, so it’s not as thoroughly tested as some other tips we’ve featured—and we’d actually recommend against using a metal hammer directly on your car as Tom does in this video—but if you’re up for venturing into semi-uncharted territory, give it a shot. Just be sure to do your research before you start and exercise caution.

Fixing a dent with hot glue | via WonderHowTo

Get Creative With WordPress – 5 Interactive Ways To Use The Platform

By Nancy Messieh, MakeUseOfApril 23, 2013 at 11:31PM

There’s quite a lot of ways you can use WordPress beyond simply using it as a blogging platform. We’ve already taken a look at a list of 5 things you might not have known you could do with WordPress.  The platform lends itself to versatility and there’s a huge variety of websites out there that you can’t even tell are created using WordPress, and there are five ways you can put the platform to use that goes beyond simply content management.

WordPress can be used to create an extremely interactive experience on your website, which can translated into a social network, a project management tool, a community board and more.

Create a Private Social Network

While there are options out there for private social networks such as Yammer, using WordPress to create that social network gives you so much more control over the experience. There are several ways to go about turning WordPress into a private social network – whether it’s using a theme or a plugin.

One of the easiest ways to get it done is to use the theme P2, which creates a Twitter-like experience, allowing you to create and add users, post updates and more.

P2 also comes with threaded comments, real-time notifications for new comments, keyboard shortcuts and more. It can be used to create a private social network, or as a live-streaming tool of your own.

You can see the theme in action on WordPress’ very own blog for its core development team.

If you’re looking for something even more elaborate, you can give BuddyPress a try. We’ve taken an in-depth look at what it has to offer, so check out our review of BuddyPress here. It allows you to create user profiles, add friends, send private messages, create user groups, discussion forums and more.

Create a Help Desk

If you want to use WordPress to incorporate a more heavy-duty customer service experience on your site, there are a few themes that will get the job done. You can create a help desk, allowing customers or users to submit questions, support tickets and more, with complete functionality to manage these submissions.

One great example of this is Woo Themes’ SupportPress.  With the paid theme, users can submit tickets, while on the backend, you can assign the tickets to members  of your team. SupportPress also goes one step further by allowing you to create a knowledge base as well so that users don’t submit duplicate tickets on questions that have already been addressed.

Support Desk is another option available to users. The responsive theme, which will set you back $50, also allows you to create a community forum and knowledge base, as well as FAQ pages. You can see the theme in action here.

If you’d rather not spend a little less in order to get a Q&A site up and running, you can opt for a plugin instead.  Q&A will set you back $19, while ClickDesk is free. The latter allows you to place a live chat feature on your site, and if you aren’t online to answer questions straight away, users can leave a message.

Create a Wiki

Another way you can get more out of WordPress is to use the CMS to create your own personal Wiki. The WordPress Wiki Theme, which costs $40, allows you to create user accounts, post content, categories and more. The theme is also completely searchable. See the theme in action here.

Woo Themes also provides users with the $50 option, Wikeasi, but if you don’t want to spend a penny, you can opt for the WordPress plugin WordPress Wiki Lite, but with the caveat of your Wiki sitting on one WordPress page within your website.

Use for GTD

WordPress can also be used as a pretty impressive productivity tool. You can use it as your own personal GTD tool or as a collaborative tool for project management.

With the plugin, Project Tasks, you can turn your WordPress website into a project management tool where you can create and assign tasks, keep track of progress and keep a log of your completed work.

If you’re looking for something even more robust, CollabPress allows you to create projects, create and assign tasks, upload files, and view tasks in a calendar.

Create a Directory, Classifieds, Jobs Board, etc.

WordPress also lends itself to creating any kind of information board or directory. You can use it to create a business directory, a jobs board or a classifieds board. No matter what kind of information you want to collate into a directory on your WordPress website, there’s likely a plugin or theme that will get the job done.

There’s nothing to stop you from creating your own Yellow Pages-like service that could become a useful resource, and with the Business Directory plugin you can even monetize the service by enabling users to submit and post to your directory for a fee.

Can you think of any other creative uses for WordPress? Let us know about them in the comments.

The post Get Creative With WordPress – 5 Interactive Ways To Use The Platform appeared first on MakeUseOf.

Canon’s ‘Super Soccer Kids’ is the Cutest Camera Commercial Ever

By Eric Reagan, Photography BayApril 23, 2013 at 07:58PM

Canon Japan’s commercial for the EOS Kiss X7 (aka the Rebel SL1) has to carry the top spot for cute camera commercials. Just look at those adorable soccer wizards go!

Why can’t we get commercials like this to air in the US?

[Hat tip to Rich Legg]

Copyright/DMCA Notice: The RSS entry was originally published on Photography Bay and is protected by copyright laws. It is unlawful to (a) edit, modify, alter, or create derivative works of the text, content or links supplied by Photography Bay, (b) use any robot, spider, scraper, other device or manual process to monitor or copy any content from the Photography Bay RSS feed, (c) sell, retransmit or commercially exploit the Photography Bay RSS feed, headlines or content in any manner except as expressly permitted in writing by authorized representatives of Photography Bay, (d) incorporate advertising into or the placement of advertising associated with or targeted towards the Photography Bay RSS feed or (e) use the Photography Bay RSS feed for any unlawful purpose or in violation of the rights of others. RSSID#794326