When I create files using < touch > command, files are now all locked. What changed?

5,128

Handuel's answer is right. If you created the files using sudo, they belong to the root user and you don't have privileges as yourself to edit them. You can check this is the case by listing the directory's contents with ls -l.

If you want to be able to modify them as yourself (your user) you should change their ownership with sudo chown youruser:yourgroup <file> (eg sudo chown matt:matt test.txt). Changing their permissions would also work (sudo chmod 777 test.txt makes it universally editable, which isn't advised, but is useful to know) but changing ownership is preferable. If you prefer the GUI, you can change ownership/permissions graphically with sudo -H nautilus and then right-clicking the relevant files to access their properties.

A lot of problems are commonly encountered when using sudo where it doesn't need to be used, like not being able to log in, or programs not starting right, so use sparingly.

Share:
5,128

Related videos on Youtube

Don
Author by

Don

Updated on September 18, 2022

Comments

  • Don
    Don over 1 year

    I am a new user of Linux and am using Ubuntu 13.04 Raring Ringtail.

    I really like the malleability of this operating system despite the fact that the common opinion, according to general information online by experienced users is that it offers limited control as compared to other Linux distributions and versions of Ubuntu.

    Anyway, my quesiton relates to why creating files for the Home directory has suddenly resulted in producing only locked files which I cannot unlock despite the fact that:

    1. I created them as a root user,
    2. I am the only user,
    3. Originally, I created several files using the ' touch ' command and they were accessible in the home directory. Now, I cannot even set the permissions for these locked files.

    Would be really interested to know what might have caused this as I don't recall changing any settings, (at least not on purpose).

    Looking forward to your replies.

  • long tom
    long tom almost 11 years
    i suggest you use chown to correct this issue. chmod will only alter permissions and there's probably no need to have root-owned files in your /home
  • Marcus
    Marcus almost 11 years
    Thanks @longtom, updated to make that clearer, and also lack of gksu on 13.04.