Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Do I risk breaking my installation of Ubuntu if I view /sbin/init without editing it, say, in gedit? (I'm taking an online Linux course and they mention this and I wanted to see what it looks like.)

share|improve this question
1  
Yep, it is fine to just view. Make sure when you click close, you don't save any changes you accidentally made. –  Tim Aug 3 at 13:55
    
Not sure what there is to "view" in /sbin/init, since it's a binary file and you'll likely get weird symbols in a text editor, but no, you'll be fine. –  saiarcot895 Aug 3 at 13:59

4 Answers 4

Yes. It's safe to view any system file(s), especially if you don't use sudo or root.

prakhar@aS4v4g3wOrld:~$ ll /sbin/init
-rwxr-xr-x 1 root root 265848 Jul 18 15:16 /sbin/init*

The owner of /sbin/init is root. The only way you can modify this file is either via logging as root ($ sudo -s) or by giving an editor superuser permissions using sudo.

Besides, /sbin/init is a binary file, not meant for reading. If you still want to view this, use a hex editor like

$ sudo apt-get install ghex
$ ghex /sbin/init

You will not be able to edit the file without superuser of course.

share|improve this answer

Sure, you can read it without doing any harm.

It's a binary file - if you are interested in the text in it, like program symbols, messages, or version numbers, use strings:

strings /sbin/init | less

/lib64/ld-linux-x86-64.so.2
I*|YB
GU1q
nx#$
BDCE
#9ym
libnih.so.1
_ITM_deregisterTMCloneTable
__gmon_start__
_Jv_RegisterClasses
_ITM_registerTMCloneTable
nih_watch_new
nih_alloc_real_set_destructor
nih_timer_add_timeout
[ ... many more lines ... ]

To see the full binary content of the file in a somewhat readable form, use hexdump:

hexdump -C /sbin/init | less

00000000  7f 45 4c 46 02 01 01 00  00 00 00 00 00 00 00 00  |.ELF............|
00000010  03 00 3e 00 01 00 00 00  e9 96 00 00 00 00 00 00  |..>.............|
00000020  40 00 00 00 00 00 00 00  78 07 04 00 00 00 00 00  |@.......x.......|
00000030  00 00 00 00 40 00 38 00  09 00 40 00 1c 00 1b 00  |....@.8...@.....|
00000040  06 00 00 00 05 00 00 00  40 00 00 00 00 00 00 00  |........@.......|
00000050  40 00 00 00 00 00 00 00  40 00 00 00 00 00 00 00  |@.......@.......|
00000060  f8 01 00 00 00 00 00 00  f8 01 00 00 00 00 00 00  |................|
00000070  08 00 00 00 00 00 00 00  03 00 00 00 04 00 00 00  |................|
00000080  38 02 00 00 00 00 00 00  38 02 00 00 00 00 00 00  |8.......8.......|
00000090  38 02 00 00 00 00 00 00  1c 00 00 00 00 00 00 00  |8...............|
000000a0  1c 00 00 00 00 00 00 00  01 00 00 00 00 00 00 00  |................|
000000b0  01 00 00 00 05 00 00 00  00 00 00 00 00 00 00 00  |................|
000000c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000d0  1c d7 03 00 00 00 00 00  1c d7 03 00 00 00 00 00  |................|
[ ... many more lines ... ]
share|improve this answer

You can view but you can't make changes. Do not save on exit init. copy the file first with

cp /sbin/init /sbin/init.me

then run

sudo nano /sbin/init.me

Here you first make a copy of the original file (init.me) then you take a look at init.me and find out what you are searching for.

share|improve this answer
    
Is there a way to view the source code somewhere? –  user223059 Aug 4 at 11:27

Yep, it is fine to just view. Make sure when you click close, you don't save any changes you accidentally made.

To be super safe, run the following command:

sudo cp /sbin/init /tmp/init.copy

then run:

sudo gedit /tmp/init.copy

So you're not viewing the original.

share|improve this answer
    
May I suggest the /tmp directory for copying the file: cp /sbin/init /tmp/init –  muru Aug 3 at 18:36
    
Yeah, good idea @muru! Wasn't sure where to put it - I didn't want ~ because it's root... –  Tim Aug 3 at 18:37
1  
Many if not most system files are world-readable, including almost all libraries and executables such as /sbin/init. It's not necessary to make a copy; opening /sbin/init as a non-root user already works, and does not risk accidental modification. If for some reason a copy is made, it is not necessary to do so as root with sudo. Furthermore, for a file foo with permissions making it unreadable to the user, sudo cp foo bar creates a file bar that is also unreadable. Therefore, might not be much application for the specific technique suggested here. –  Eliah Kagan Aug 4 at 4:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.